Progress on navigation
This commit is contained in:
parent
fb3d366fe0
commit
fcea4cb305
5 changed files with 28 additions and 11 deletions
|
@ -20,14 +20,9 @@ export function doNavigate(path) {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
const previousPath = selectCurrentPath(state)
|
const previousPath = selectCurrentPath(state)
|
||||||
const previousTitle = selectPageTitle(state)
|
const previousTitle = selectPageTitle(state)
|
||||||
history.pushState(state, previousTitle, previousPath);
|
history.pushState({}, previousTitle, previousPath);
|
||||||
|
|
||||||
dispatch({
|
dispatch(doChangePath(path))
|
||||||
type: types.NAVIGATE,
|
|
||||||
data: {
|
|
||||||
path,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const pageTitle = selectPageTitle(state)
|
const pageTitle = selectPageTitle(state)
|
||||||
|
|
||||||
|
@ -35,6 +30,15 @@ export function doNavigate(path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function doChangePath(path) {
|
||||||
|
return {
|
||||||
|
type: types.CHANGE_PATH,
|
||||||
|
data: {
|
||||||
|
path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function doLogoClick() {
|
export function doLogoClick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export const NAVIGATE = 'NAVIGATE'
|
export const CHANGE_PATH = 'CHANGE_PATH'
|
||||||
export const OPEN_MODAL = 'OPEN_MODAL'
|
export const OPEN_MODAL = 'OPEN_MODAL'
|
||||||
export const CLOSE_MODAL = 'CLOSE_MODAL'
|
export const CLOSE_MODAL = 'CLOSE_MODAL'
|
||||||
export const HISTORY_BACK = 'HISTORY_BACK'
|
export const HISTORY_BACK = 'HISTORY_BACK'
|
||||||
|
|
|
@ -11,7 +11,8 @@ import { Provider } from 'react-redux';
|
||||||
import store from 'store.js';
|
import store from 'store.js';
|
||||||
import { runTriggers } from 'triggers'
|
import { runTriggers } from 'triggers'
|
||||||
import {
|
import {
|
||||||
doDaemonReady
|
doDaemonReady,
|
||||||
|
doChangePath,
|
||||||
} from 'actions/app'
|
} from 'actions/app'
|
||||||
|
|
||||||
const {remote} = require('electron');
|
const {remote} = require('electron');
|
||||||
|
@ -26,6 +27,18 @@ window.addEventListener('contextmenu', (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener('popstate', (event) => {
|
||||||
|
let pathname = document.location.pathname
|
||||||
|
if (pathname.match(/dist/))
|
||||||
|
pathname = '/discover'
|
||||||
|
|
||||||
|
app.store.dispatch(doChangePath(pathname))
|
||||||
|
})
|
||||||
|
|
||||||
|
if (window.location.hash != '') {
|
||||||
|
window.history.pushState({}, "Discover", location.hash.substring(2));
|
||||||
|
}
|
||||||
|
|
||||||
const initialState = app.store.getState();
|
const initialState = app.store.getState();
|
||||||
app.store.subscribe(runTriggers);
|
app.store.subscribe(runTriggers);
|
||||||
runTriggers();
|
runTriggers();
|
||||||
|
|
|
@ -19,7 +19,7 @@ reducers[types.DAEMON_READY] = function(state, action) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
reducers[types.NAVIGATE] = function(state, action) {
|
reducers[types.CHANGE_PATH] = function(state, action) {
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
currentPath: action.data.path,
|
currentPath: action.data.path,
|
||||||
})
|
})
|
||||||
|
|
|
@ -22,7 +22,7 @@ export const selectCurrentPage = createSelector(
|
||||||
(path, searchActivated) => {
|
(path, searchActivated) => {
|
||||||
if (searchActivated) return 'search'
|
if (searchActivated) return 'search'
|
||||||
|
|
||||||
return path.split('=')[0]
|
return path.replace(/^\//, '').split('=')[0]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue