From 8d7891a25bbf94d5c678b71379519453ed846e55 Mon Sep 17 00:00:00 2001
From: Renard
Date: Mon, 23 Sep 2019 22:14:00 -0300
Subject: Lista de hilos
---
src/App.js | 6 ++++
src/Board.js | 15 +++++++++-
src/ThreadList.js | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 104 insertions(+), 1 deletion(-)
create mode 100644 src/ThreadList.js
(limited to 'src')
diff --git a/src/App.js b/src/App.js
index 864eaa2..399d8a1 100644
--- a/src/App.js
+++ b/src/App.js
@@ -16,6 +16,7 @@ import Home from "./Home";
import Thread from "./Thread";
import Board from "./Board";
import NotFound from "./NotFound";
+import ThreadList from "./ThreadList";
class App extends Component {
constructor() {
@@ -140,6 +141,11 @@ class App extends Component {
path="/board/:dir"
nightMode={this.state.nightMode}
/>
+
diff --git a/src/Board.js b/src/Board.js
index 41727bc..b15f050 100644
--- a/src/Board.js
+++ b/src/Board.js
@@ -35,7 +35,12 @@ class Board extends Component {
if (resource["state"] === "error") {
this.setState({ error: resource });
}
- this.setState({ isLoaded: true, threadList: resource["threads"] });
+ this.setState(
+ { isLoaded: true, threadList: resource["threads"] },
+ () => {
+ window.scrollTo(0, 0);
+ }
+ );
});
window.scrollTo(0, 0);
window.addEventListener("scroll", this.handleScroll);
@@ -127,6 +132,14 @@ class Board extends Component {
{currentBoard.name}
+
+
+ {currentBoard.name}
+ /{currentBoard.dir}/
+
+ Lista de hilos
+
+
{threadList.map(thread => (
diff --git a/src/ThreadList.js b/src/ThreadList.js
new file mode 100644
index 0000000..c5eb990
--- /dev/null
+++ b/src/ThreadList.js
@@ -0,0 +1,84 @@
+import React, { Component } from "react";
+import { Header, Loader, List, Card, Image, Icon } from "semantic-ui-react";
+import { Link } from "@reach/router";
+import Moment from "react-moment";
+import "moment/locale/es";
+
+class ThreadList extends Component {
+ constructor(props) {
+ super(props);
+ this.state = { isLoading: true, threadList: [] };
+ }
+
+ componentDidMount() {
+ const { dir } = this.props;
+ fetch(
+ `https://bienvenidoainternet.org/cgi/api/list?dir=${dir}&replies=0&limit=30&nohtml=1`
+ )
+ .then(response => {
+ return response.json();
+ })
+ .then(resource => {
+ this.setState({ threadList: resource.threads, isLoading: false });
+ });
+ }
+
+ render() {
+ const { dir, boardList } = this.props;
+ const { threadList, isLoading } = this.state;
+
+ const currentBoard = boardList.find(board => {
+ return board.dir === dir;
+ });
+
+ if (isLoading) {
+ return (
+
+ Cargando lista de hilos ...
+
+ );
+ }
+
+ const stripHtml = RegExp(
+ /(