From cd9b802b71df4e2701e2311b2995fe70a9692ae4 Mon Sep 17 00:00:00 2001 From: Renard Date: Mon, 16 Sep 2019 01:22:56 -0300 Subject: Prettier --- src/Thread.js | 171 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 99 insertions(+), 72 deletions(-) (limited to 'src/Thread.js') diff --git a/src/Thread.js b/src/Thread.js index 085a754..4d0f56d 100644 --- a/src/Thread.js +++ b/src/Thread.js @@ -1,92 +1,119 @@ import React, { Component } from "react"; -import { Header, Icon, Loader, Message, Segment, Comment } from "semantic-ui-react"; +import { + Header, + Icon, + Loader, + Message, + Segment, + Comment +} from "semantic-ui-react"; import Moment from "react-moment"; import "moment/locale/es"; import Post from "./Post"; import ReplyForm from "./ReplyForm"; class Thread extends Component { - constructor(props) { - super(props); - this.state = { - isLoading: true, - thread: [], - error: null - } - } - - componentDidMount() { + constructor(props) { + super(props); + this.state = { + isLoading: true, + thread: [], + error: null + }; + } - let apiURl; - if (this.props.id > 1000000) { - apiURl = `https://bienvenidoainternet.org/cgi/api/thread?dir=${this.props.dir}&ts=${this.props.id}`; - } else { - apiURl = `https://bienvenidoainternet.org/cgi/api/thread?dir=${this.props.dir}&id=${this.props.id}`; - } - console.log(apiURl); - fetch(apiURl) - .then((response) => { return response.json() }) - .then((resource => { - if (resource["state"] === "error") { - console.log("API Error:" + resource["message"]); - this.setState({ error: resource }); - } - this.setState({ isLoading: false, thread: resource }); - })) - .catch(console.error); + componentDidMount() { + let apiURl; + if (this.props.id > 1000000) { + apiURl = `https://bienvenidoainternet.org/cgi/api/thread?dir=${this.props.dir}&ts=${this.props.id}`; + } else { + apiURl = `https://bienvenidoainternet.org/cgi/api/thread?dir=${this.props.dir}&id=${this.props.id}`; } - render() { - const { isLoading, error } = this.state; - - if (isLoading) { - return ( - - Cargando ... - - ) + console.log(apiURl); + fetch(apiURl) + .then(response => { + return response.json(); + }) + .then(resource => { + if (resource["state"] === "error") { + console.log("API Error:" + resource["message"]); + this.setState({ error: resource }); } + this.setState({ isLoading: false, thread: resource }); + }) + .catch(console.error); + } + render() { + const { isLoading, error } = this.state; - if (error != null) { - return ( -
- - API Status: {error.state} -

{error.message}

-
-
- ); - } - - const { posts, subject, timestamp, total_replies, locked, id } = this.state.thread; - document.title = subject; + if (isLoading) { + return ( + + Cargando ... + + ); + } - return ( -
-
- - {subject}{locked ? : null} - + if (error != null) { + return ( +
+ + API Status: {error.state} +

{error.message}

+
+
+ ); + } - + const { + posts, + subject, + timestamp, + total_replies, + locked, + id + } = this.state.thread; + document.title = subject; - Creado
- {total_replies} respuestas
+ return ( +
+
+ + {subject} + {locked ? : null} + - -
+ + Creado +
+ {total_replies} respuestas +
+
+
- - {posts.map((post, index) => - - ) - } - + + {posts.map((post, index) => ( + + ))} + - + - API Link -
); - } + + API Link + + + ); + } } -export default Thread; \ No newline at end of file +export default Thread; -- cgit v1.2.1-18-gbd029