From 2e496411a387493e87087d90deb4ed5efe3c3417 Mon Sep 17 00:00:00 2001
From: Renard
Date: Wed, 25 Sep 2019 15:33:33 -0300
Subject: Variable destructuring ✨
---
src/App.js | 42 ++++++++++++++++--------------------------
src/Board.js | 10 ++++------
src/Post.js | 12 +++++++++---
src/ReplyForm.js | 4 ++--
src/Thread.js | 8 ++++----
5 files changed, 35 insertions(+), 41 deletions(-)
(limited to 'src')
diff --git a/src/App.js b/src/App.js
index 399d8a1..a725b29 100644
--- a/src/App.js
+++ b/src/App.js
@@ -61,18 +61,16 @@ class App extends Component {
}
render() {
- if (!this.state.isLoaded) {
- if (!this.state.isLoaded) {
- return (
-
- Cargando ...
-
- );
- }
+ const { boardList, nightMode, isLoaded } = this.state;
+
+ if (!isLoaded) {
+ return (
+
+ Cargando ...
+
+ );
}
- const { boardList } = this.state;
- //const pathList = boardList.map(board => "/" + board.dir)
return (
-
+
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 (
@@ -143,9 +143,7 @@ class Board extends Component {
{threadList.map(thread => (
-
- {thread.subject}
-
+ {thread.subject}
{thread.total_replies} respuestas
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 (
@@ -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(
' {
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 (
Hilo cerrado
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 {
/>
API Link
--
cgit v1.2.1-18-gbd029