import React from 'react'; import { clearUserCookies } from 'utils/cookies'; import { authenticateUser } from 'utils/auth'; import Logo from 'components/Logo'; import NavBarChannelDropdown from 'components/NavBarChannelDropdown'; const VIEW = 'VIEW'; const LOGOUT = 'LOGOUT'; class NavBar extends React.Component { constructor (props) { super(props); this.checkForLoggedInUser = this.checkForLoggedInUser.bind(this); this.logoutUser = this.logoutUser.bind(this); this.handleSelection = this.handleSelection.bind(this); } componentDidMount () { // check to see if the user is already logged in this.checkForLoggedInUser(); } checkForLoggedInUser () { // check for whether a channel is already logged in authenticateUser() .then(({success, message}) => { if (success) { this.props.onChannelLogin(message.channelName, message.shortChannelId, message.channelClaimId); } else { console.log('user was not logged in'); } }) .catch(error => { console.log('authenticate user errored:', error); }); } logoutUser () { // send logout request to server window.location.href = '/logout'; // NOTE: replace with a call to the server } handleSelection (event) { console.log('handling selection', event); const value = event.target.selectedOptions[0].value; console.log('value', value); switch (value) { case LOGOUT: this.logoutUser(); break; case VIEW: // redirect to channel page window.location.href = `/${this.props.channelName}:${this.props.channelLongId}`; break; default: break; } } render () { return (
Open-source, decentralized image and video sharing.
Publish About { this.props.channelName ? ( ) : ( Channel )}
); } } export default NavBar;