Lint routes.js
This commit is contained in:
parent
2beb872de9
commit
6075767960
@ -1,31 +1,29 @@
|
||||
import React from 'react'
|
||||
import MovieList from "./components/movies/list"
|
||||
import ShowList from "./components/shows/list"
|
||||
import ShowDetails from "./components/shows/details"
|
||||
import UserLoginForm from "./components/users/login"
|
||||
import UserEdit from "./components/users/edit"
|
||||
import UserSignUp from "./components/users/signup"
|
||||
import TorrentList from "./components/torrents/list"
|
||||
|
||||
import MovieList from './components/movies/list'
|
||||
import ShowList from './components/shows/list'
|
||||
import ShowDetails from './components/shows/details'
|
||||
import UserLoginForm from './components/users/login'
|
||||
import UserEdit from './components/users/edit'
|
||||
import UserSignUp from './components/users/signup'
|
||||
import TorrentList from './components/torrents/list'
|
||||
import { fetchTorrents } from "./actions/torrents"
|
||||
import { userLogout, getUserInfos } from "./actions/users"
|
||||
import { fetchMovies, getMovieExploreOptions } from "./actions/movies"
|
||||
import { fetchShows, fetchShowDetails, getShowExploreOptions } from "./actions/shows"
|
||||
|
||||
import { fetchTorrents } from './actions/torrents'
|
||||
import { userLogout, getUserInfos } from './actions/users'
|
||||
import { fetchMovies, getMovieExploreOptions } from './actions/movies'
|
||||
import { fetchShows, fetchShowDetails, getShowExploreOptions } from './actions/shows'
|
||||
|
||||
import store from './store'
|
||||
import store from "./store"
|
||||
|
||||
// This function returns true if the user is logged in, false otherwise
|
||||
function isLoggedIn() {
|
||||
const state = store.getState();
|
||||
const isLogged = state.userStore.isLogged;
|
||||
let token = localStorage.getItem('token');
|
||||
let token = localStorage.getItem("token");
|
||||
|
||||
// Let's check if the user has a token, if he does let's assume he's logged
|
||||
// in. If that's not the case he will be logged out on the fisrt query
|
||||
if (token && token !== "") {
|
||||
store.dispatch({
|
||||
type: 'USER_SET_TOKEN',
|
||||
type: "USER_SET_TOKEN",
|
||||
payload: {
|
||||
token: token,
|
||||
},
|
||||
@ -43,7 +41,7 @@ var pollingTorrentsId;
|
||||
const loginCheck = function(nextState, replace, next, f = null) {
|
||||
const loggedIn = isLoggedIn();
|
||||
if (!loggedIn) {
|
||||
replace('/users/login');
|
||||
replace("/users/login");
|
||||
} else {
|
||||
if (f) {
|
||||
f();
|
||||
@ -61,19 +59,19 @@ const loginCheck = function(nextState, replace, next, f = null) {
|
||||
next();
|
||||
}
|
||||
|
||||
const defaultRoute = '/movies/explore/yts/seeds';
|
||||
const defaultRoute = "/movies/explore/yts/seeds";
|
||||
export default function getRoutes(App) {
|
||||
return {
|
||||
path: '/',
|
||||
path: "/",
|
||||
component: App,
|
||||
indexRoute: {onEnter: ({params}, replace) => replace(defaultRoute)},
|
||||
childRoutes: [
|
||||
{
|
||||
path: '/users/signup',
|
||||
path: "/users/signup",
|
||||
component: UserSignUp
|
||||
},
|
||||
{
|
||||
path: '/users/login',
|
||||
path: "/users/login",
|
||||
component: UserLoginForm,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
if (isLoggedIn()) {
|
||||
@ -84,7 +82,7 @@ export default function getRoutes(App) {
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/users/edit',
|
||||
path: "/users/edit",
|
||||
component: UserEdit,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
loginCheck(nextState, replace, next, function() {
|
||||
@ -93,7 +91,7 @@ export default function getRoutes(App) {
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/users/logout',
|
||||
path: "/users/logout",
|
||||
onEnter: function(nextState, replace, next) {
|
||||
// Stop polling
|
||||
if (pollingTorrentsId !== null) {
|
||||
@ -101,12 +99,12 @@ export default function getRoutes(App) {
|
||||
pollingTorrentsId = null;
|
||||
}
|
||||
store.dispatch(userLogout());
|
||||
replace('/users/login');
|
||||
replace("/users/login");
|
||||
next();
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/movies/search/:search',
|
||||
path: "/movies/search/:search",
|
||||
component: MovieList,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
loginCheck(nextState, replace, next, function() {
|
||||
@ -115,22 +113,22 @@ export default function getRoutes(App) {
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/movies/polochon',
|
||||
path: "/movies/polochon",
|
||||
component: MovieList,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
loginCheck(nextState, replace, next, function() {
|
||||
store.dispatch(fetchMovies('/movies/polochon'));
|
||||
store.dispatch(fetchMovies("/movies/polochon"));
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/movies/explore/:source/:category',
|
||||
path: "/movies/explore/:source/:category",
|
||||
component: MovieList,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
loginCheck(nextState, replace, next, function() {
|
||||
var state = store.getState();
|
||||
// Fetch the explore options
|
||||
if (state.movieStore.get('exploreOptions').size === 0) {
|
||||
if (state.movieStore.get("exploreOptions").size === 0) {
|
||||
store.dispatch(getMovieExploreOptions());
|
||||
}
|
||||
store.dispatch(fetchMovies(
|
||||
@ -140,16 +138,16 @@ export default function getRoutes(App) {
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/movies/wishlist',
|
||||
path: "/movies/wishlist",
|
||||
component: MovieList,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
loginCheck(nextState, replace, next, function() {
|
||||
store.dispatch(fetchMovies('/wishlist/movies'));
|
||||
store.dispatch(fetchMovies("/wishlist/movies"));
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/shows/search/:search',
|
||||
path: "/shows/search/:search",
|
||||
component: ShowList,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
loginCheck(nextState, replace, next, function() {
|
||||
@ -158,25 +156,25 @@ export default function getRoutes(App) {
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/shows/polochon',
|
||||
path: "/shows/polochon",
|
||||
component: ShowList,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
loginCheck(nextState, replace, next, function() {
|
||||
store.dispatch(fetchShows('/shows/polochon'));
|
||||
store.dispatch(fetchShows("/shows/polochon"));
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/shows/wishlist',
|
||||
path: "/shows/wishlist",
|
||||
component: ShowList,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
loginCheck(nextState, replace, next, function() {
|
||||
store.dispatch(fetchShows('/wishlist/shows'));
|
||||
store.dispatch(fetchShows("/wishlist/shows"));
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/shows/details/:imdbId',
|
||||
path: "/shows/details/:imdbId",
|
||||
component: ShowDetails,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
loginCheck(nextState, replace, next, function() {
|
||||
@ -185,13 +183,13 @@ export default function getRoutes(App) {
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/shows/explore/:source/:category',
|
||||
path: "/shows/explore/:source/:category",
|
||||
component: ShowList,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
loginCheck(nextState, replace, next, function() {
|
||||
var state = store.getState();
|
||||
// Fetch the explore options
|
||||
if (state.showsStore.get('exploreOptions').size === 0) {
|
||||
if (state.showsStore.get("exploreOptions").size === 0) {
|
||||
store.dispatch(getShowExploreOptions());
|
||||
}
|
||||
store.dispatch(fetchShows(
|
||||
@ -201,7 +199,7 @@ export default function getRoutes(App) {
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/torrents',
|
||||
path: "/torrents",
|
||||
component: TorrentList,
|
||||
onEnter: function(nextState, replace, next) {
|
||||
loginCheck(nextState, replace, next, function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user