diff options
-rw-r--r-- | src/App.js | 42 | ||||
-rw-r--r-- | src/Board.js | 10 | ||||
-rw-r--r-- | src/Post.js | 12 | ||||
-rw-r--r-- | src/ReplyForm.js | 4 | ||||
-rw-r--r-- | src/Thread.js | 8 |
5 files changed, 35 insertions, 41 deletions
@@ -61,18 +61,16 @@ class App extends Component { } render() { - if (!this.state.isLoaded) { - if (!this.state.isLoaded) { - return ( - <Loader active centered="true"> - Cargando ... - </Loader> - ); - } + const { boardList, nightMode, isLoaded } = this.state; + + if (!isLoaded) { + return ( + <Loader active centered="true"> + Cargando ... + </Loader> + ); } - const { boardList } = this.state; - //const pathList = boardList.map(board => "/" + board.dir) return ( <React.Fragment> <Menu inverted fixed="top"> @@ -113,38 +111,30 @@ class App extends Component { </Dropdown> <Menu.Menu position="right"> <Menu.Item as="a" onClick={this.toggleTheme}> - {this.state.nightMode ? ( - <Icon name="sun" /> - ) : ( - <Icon name="moon" /> - )} + {nightMode ? <Icon name="sun" /> : <Icon name="moon" />} </Menu.Item> </Menu.Menu> </Container> </Menu> <Container className="main"> <Router> - <Home - boardList={this.state.boardList} - path="/" - nightMode={this.state.nightMode} - /> + <Home boardList={boardList} path="/" nightMode={nightMode} /> <Thread - boardList={this.state.boardList} + boardList={boardList} path="/:dir/read/:id" - nightMode={this.state.nightMode} + nightMode={nightMode} > <Thread path=":active" /> </Thread> <Board - boardList={this.state.boardList} + boardList={boardList} path="/board/:dir" - nightMode={this.state.nightMode} + nightMode={nightMode} /> <ThreadList - boardList={this.state.boardList} + boardList={boardList} path="/list/:dir" - nightMode={this.state.nightMode} + nightMode={nightMode} /> <NotFound default /> </Router> diff --git a/src/Board.js b/src/Board.js index 593f766..048cb00 100644 --- a/src/Board.js +++ b/src/Board.js @@ -97,6 +97,7 @@ class Board extends Component { render() { const { isLoaded, error, threadList, loadingMore, endReached } = this.state; + const { boardList, dir, nightMode } = this.props; if (error != null) { return ( @@ -117,11 +118,10 @@ class Board extends Component { ); } - const currentBoard = this.props.boardList.find(board => { - return board.dir === this.props.dir; + const currentBoard = boardList.find(board => { + return board.dir === dir; }); document.title = currentBoard.name + " - B.a.I"; - const nightMode = this.props.nightMode; return ( <React.Fragment> @@ -143,9 +143,7 @@ class Board extends Component { {threadList.map(thread => ( <Segment.Group key={"seg_" + thread.timestamp + thread.id}> <Header as="h3" attached inverted={nightMode}> - <Link to={`/${this.props.dir}/read/${thread.id}`}> - {thread.subject} - </Link> + <Link to={`/${dir}/read/${thread.id}`}>{thread.subject}</Link> <Header.Subheader> {thread.total_replies} respuestas </Header.Subheader> diff --git a/src/Post.js b/src/Post.js index 9a467cb..8193ec1 100644 --- a/src/Post.js +++ b/src/Post.js @@ -69,6 +69,9 @@ const QuickReplyModal = ({ trigger, currentBoard, id, locked, replyIndex }) => ( ); const Post = ({ index, post, locked, threadId, currentBoard, nightMode }) => { + const filesize = require("filesize"); + + // Manejo de posts eliminados if (post.IS_DELETED > 0) { return ( <Comment> @@ -94,8 +97,8 @@ const Post = ({ index, post, locked, threadId, currentBoard, nightMode }) => { ); } + // Obtener un avatar aleatorio basado en ID let user_id = post.timestamp_formatted.split(" ID:")[1]; - const filesize = require("filesize"); const seedrandom = require("seedrandom"); const rng = seedrandom(threadId + index); const idRng = seedrandom(user_id); @@ -119,8 +122,8 @@ const Post = ({ index, post, locked, threadId, currentBoard, nightMode }) => { hue = Math.round(rng() * 360); } + // Obetener bandera del pais (para /world) let flag; - if (currentBoard.dir === "world") { flag = post.name.match("[A-Z][A-Z]"); if (flag !== null) { @@ -130,11 +133,13 @@ const Post = ({ index, post, locked, threadId, currentBoard, nightMode }) => { } } + // Fix: imagenes en dominio incorrecto post.message = post.message.replace( '<img src="/', '<img src="https://bienvenidoainternet.org/' ); + // Fix para reach-router if (currentBoard.board_type === 0) { post.message = post.message.replace("/res/", "/read/"); post.message = post.message.replace(".html#", "/"); @@ -143,7 +148,8 @@ const Post = ({ index, post, locked, threadId, currentBoard, nightMode }) => { if (post.tripcode === " (★ ****-****)") { post.tripcode = ""; } - //(?:https?:\/\/)?(?:www\.)?youtu(.be\/|be\.com\/watch\?v=)(\w{11}) + + // Obtener lista de videos de youtube incrustados const youtubeRe = RegExp( /(?:https?:\/\/)?(?:www\.)?youtu(.be\/|be\.com\/watch\?v=)(\w{11})/g ); diff --git a/src/ReplyForm.js b/src/ReplyForm.js index 8c942e7..33b33a0 100644 --- a/src/ReplyForm.js +++ b/src/ReplyForm.js @@ -86,8 +86,8 @@ class ReplyForm extends Component { render() { const { name, email, message, replyRes, attachment } = this.state; - const { currentBoard, nightMode, quickReply } = this.props; - if (this.props.locked === 1) { + const { currentBoard, nightMode, quickReply, locked } = this.props; + if (locked === 1) { return ( <Message negative> <Message.Header>Hilo cerrado</Message.Header> diff --git a/src/Thread.js b/src/Thread.js index 5c42aaa..c4d4cbe 100644 --- a/src/Thread.js +++ b/src/Thread.js @@ -101,7 +101,7 @@ class Thread extends Component { render() { const { isLoading, error } = this.state; - const { nightMode } = this.props; + const { boardList, dir, nightMode } = this.props; if (isLoading) { return ( @@ -131,8 +131,8 @@ class Thread extends Component { id } = this.state.thread; - const currentBoard = this.props.boardList.find(board => { - return board.dir === this.props.dir; + const currentBoard = boardList.find(board => { + return board.dir === dir; }); document.title = subject + " - " + currentBoard.name + "@B.a.I"; @@ -185,7 +185,7 @@ class Thread extends Component { /> <a - href={`https://bienvenidoainternet.org/cgi/api/thread?dir=${this.props.dir}&id=${this.props.id}`} + href={`https://bienvenidoainternet.org/cgi/api/thread?dir=${dir}&id=${this.props.id}`} > API Link </a> |