import React, { Component } from "react"; import { Loader, Icon, Item, Segment } 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, nightMode } = 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( /()|()|()|(<\/?(\s|\S)*?>)/g ); return ( {threadList.map((thread, index) => { return ( {currentBoard.allow_images === 1 && ( )} {thread.subject} {thread.message.replace(stripHtml, "").substring(0, 200) + " ..."} {thread.total_replies} Respuestas ); })} ); } } export default ThreadList;