import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter as Router, Route, Link, Switch, Redirect } from 'react-router-dom'; import * as qs from 'query-string'; import Icon from './components/Icon'; import { Discover, Discussions, Blog, Tag, Home } from './components/Feeds'; import Settings from './components/Settings'; import Contacts from './components/Contacts'; import Chat from './components/Chat'; import Post from './components/Post'; import Thread from './components/Thread'; import LoginButton from './components/LoginButton'; import Footer from './components/Footer'; import Avatar from './components/Avatar'; import Header from './components/Header'; import SearchBox from './components/SearchBox'; import { me } from './api'; class App extends React.Component { constructor(props) { super(props); let params = qs.parse(window.location.search) if (params.hash) { localStorage.visitor = JSON.stringify({uid: 0, hash: params.hash}); window.history.replaceState({}, document.title, `${window.location.protocol}//${window.location.host}${window.location.pathname}`) } this.state = { visitor: localStorage.visitor ? JSON.parse(localStorage.visitor) : { uid: 0, hash: params.hash || '' } }; } componentDidMount() { const {hash, uid} = this.state.visitor; if (uid === 0 && hash) { me().then(visitor => this.auth(visitor)) } } search = (searchString) => { console.log(searchString) } render() { const user = this.state.visitor; return (
{user.uid > 0 ?
{user.uname ? : }
: }
} /> } /> } /> } /> } /> } /> } /> } /> } /> } />