mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-22 08:25:14 +00:00
0.0.6
- Fix hitting dashboard when logged out - Clean up app.js
This commit is contained in:
parent
2f8aa2e502
commit
0c56281bcd
@ -3,7 +3,7 @@ stages:
|
|||||||
- bundle
|
- bundle
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
VERSION: 0.0.5
|
VERSION: 0.0.6
|
||||||
|
|
||||||
build-go:
|
build-go:
|
||||||
image: golang:1.16.2
|
image: golang:1.16.2
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
# 0.0.6
|
||||||
|
- Fix hitting dashboard when logged out
|
||||||
|
- Clean up app.js
|
||||||
|
|
||||||
# 0.0.5
|
# 0.0.5
|
||||||
- Only allow ItemType:Audio from Jellyfin
|
- Only allow ItemType:Audio from Jellyfin
|
||||||
- Fix NavBar for Mobile (Ugly hack but.. TO REWORK)
|
- Fix NavBar for Mobile (Ugly hack but.. TO REWORK)
|
||||||
|
@ -3,11 +3,13 @@ import {
|
|||||||
REGISTER_FAIL,
|
REGISTER_FAIL,
|
||||||
LOGIN_SUCCESS,
|
LOGIN_SUCCESS,
|
||||||
LOGIN_FAIL,
|
LOGIN_FAIL,
|
||||||
} from "./types";
|
LOGOUT,
|
||||||
|
} from "./types";
|
||||||
|
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import jwt from 'jwt-decode'
|
import jwt from 'jwt-decode'
|
||||||
import AuthService from "../Services/auth.service";
|
import AuthService from "../Services/auth.service";
|
||||||
|
import eventBus from "./eventBus";
|
||||||
|
|
||||||
export const register = (username, email, password) => (dispatch) => {
|
export const register = (username, email, password) => (dispatch) => {
|
||||||
return AuthService.register(username, email, password).then(
|
return AuthService.register(username, email, password).then(
|
||||||
@ -85,12 +87,19 @@ import {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const logout = () => (dispatch) => {
|
export const logout = (dispatch) => {
|
||||||
AuthService.logout();
|
// Clear local data
|
||||||
|
AuthService.logout()
|
||||||
|
|
||||||
// dispatch({
|
// window.location.pathname("/")
|
||||||
// type: LOGOUT,
|
window.location.reload()
|
||||||
// });
|
|
||||||
|
|
||||||
window.location.reload();
|
// TODO; Clear Redux - ENABLE THIS WHEN I FIGURE OUT HOW 2 DISPATCH
|
||||||
|
// dispatch({
|
||||||
|
// type: LOGOUT,
|
||||||
|
// payload: {},
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Issue to all listeners to reload
|
||||||
|
eventBus.dispatch(LOGOUT);
|
||||||
};
|
};
|
||||||
|
@ -12,52 +12,23 @@ import Navigation from './Components/Navigation';
|
|||||||
|
|
||||||
// import { logout } from './Actions/auth';
|
// import { logout } from './Actions/auth';
|
||||||
import { Route, Switch, withRouter } from 'react-router-dom';
|
import { Route, Switch, withRouter } from 'react-router-dom';
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import { Component } from 'react';
|
import { Component } from 'react';
|
||||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
|
||||||
const { user } = state.auth;
|
|
||||||
return {
|
|
||||||
user,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
// this.logOut = this.logOut.bind(this);
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
// showAdminBoard: false,
|
|
||||||
// currentUser: undefined,
|
|
||||||
// Don't even ask.. apparently you can't pass
|
|
||||||
// exact="true".. it has to be a bool :|
|
|
||||||
true: true,
|
true: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// componentDidMount() {
|
|
||||||
// const user = this.props.user;
|
|
||||||
|
|
||||||
// if (user) {
|
|
||||||
// this.setState({
|
|
||||||
// currentUser: user,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// logOut() {
|
|
||||||
// this.props.dispatch(logout());
|
|
||||||
// }
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Navigation />
|
<Navigation />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact={this.state.true} path="/" component={Home} />
|
<Route exact={this.state.true} path={["/", "/home"]} component={Home} />
|
||||||
<Route path="/about" component={About} />
|
<Route path="/about" component={About} />
|
||||||
|
|
||||||
<Route path="/dashboard" component={Dashboard} />
|
<Route path="/dashboard" component={Dashboard} />
|
||||||
@ -68,9 +39,11 @@ class App extends Component {
|
|||||||
|
|
||||||
<Route path="/login" component={Login} />
|
<Route path="/login" component={Login} />
|
||||||
<Route path="/register" component={Register} />
|
<Route path="/register" component={Register} />
|
||||||
|
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default withRouter(connect(mapStateToProps)(App));
|
|
||||||
|
export default withRouter(App);
|
@ -30,10 +30,11 @@ class Navigation extends Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.toggleNavbar = this.toggleNavbar.bind(this);
|
this.toggleNavbar = this.toggleNavbar.bind(this);
|
||||||
|
this.handleLogout = this.handleLogout.bind(this);
|
||||||
|
|
||||||
// Yeah I know you might not hit home.. but I can't get the
|
// Yeah I know you might not hit home.. but I can't get the
|
||||||
// path based finder thing working on initial load :sweatsmile:
|
// path based finder thing working on initial load :sweatsmile:
|
||||||
this.state = { active: "Home", collapsed: true};
|
this.state = { active: "Home", collapsed: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -55,13 +56,16 @@ class Navigation extends Component {
|
|||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
eventBus.remove(LOGIN_SUCCESS);
|
eventBus.remove(LOGIN_SUCCESS);
|
||||||
eventBus.remove(LOGOUT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleClick(menuItem) {
|
_handleClick(menuItem) {
|
||||||
this.setState({ active: menuItem, collapsed: !this.state.collapsed });
|
this.setState({ active: menuItem, collapsed: !this.state.collapsed });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleLogout() {
|
||||||
|
this.dispatch(logout());
|
||||||
|
}
|
||||||
|
|
||||||
toggleNavbar() {
|
toggleNavbar() {
|
||||||
this.setState({ collapsed: !this.state.collapsed });
|
this.setState({ collapsed: !this.state.collapsed });
|
||||||
}
|
}
|
||||||
@ -94,7 +98,7 @@ class Navigation extends Component {
|
|||||||
onClick={this._handleClick.bind(this, "profile")}
|
onClick={this._handleClick.bind(this, "profile")}
|
||||||
className="navLinkMobile"
|
className="navLinkMobile"
|
||||||
>Profile</Link>
|
>Profile</Link>
|
||||||
<Link to="/" className="navLink" onClick={logout()}>Logout</Link>
|
<Link to="/" className="navLink" onClick={this.handleLogout}>Logout</Link>
|
||||||
</Nav>
|
</Nav>
|
||||||
: <Nav className="navLinkLoginMobile" navbar>
|
: <Nav className="navLinkLoginMobile" navbar>
|
||||||
{menuItems.map(menuItem =>
|
{menuItems.map(menuItem =>
|
||||||
@ -172,7 +176,7 @@ class Navigation extends Component {
|
|||||||
onClick={this._handleClick.bind(this, "profile")}
|
onClick={this._handleClick.bind(this, "profile")}
|
||||||
className="navLink"
|
className="navLink"
|
||||||
>Profile</Link>
|
>Profile</Link>
|
||||||
<Link to="/" className="navLink" onClick={logout()}>Logout</Link>
|
<Link to="/" className="navLink" onClick={this.handleLogout}>Logout</Link>
|
||||||
</div>
|
</div>
|
||||||
:
|
:
|
||||||
<div className="navLinkLogin">
|
<div className="navLinkLogin">
|
||||||
@ -209,8 +213,9 @@ class Navigation extends Component {
|
|||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
const { isLoggedIn } = state.auth;
|
const { isLoggedIn } = state.auth;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isLoggedIn,
|
isLoggedIn
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,10 @@ class Dashboard extends React.Component {
|
|||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
const { isLoggedIn } = state.auth;
|
const { isLoggedIn } = state.auth;
|
||||||
const { uuid } = state.auth.user;
|
let uuid = null;
|
||||||
|
if (isLoggedIn) {
|
||||||
|
uuid = state.auth.user.uuid
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
|
@ -20,7 +20,7 @@ class AuthService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
async logout() {
|
||||||
localStorage.removeItem("user");
|
localStorage.removeItem("user");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user