Don't navigate when deselecting due to navigation

This commit is contained in:
Drew DeVault 2017-08-25 20:01:31 -04:00
parent cc414c9b57
commit 0050f12c65
2 changed files with 9 additions and 7 deletions

View File

@ -6,7 +6,7 @@ export const UNION = 'UNION';
export const SUBTRACT = 'SUBTRACT'; export const SUBTRACT = 'SUBTRACT';
export const EXCLUSIVE = 'EXCLUSIVE'; export const EXCLUSIVE = 'EXCLUSIVE';
export default function selectTorrent(ids, action) { export default function selectTorrent(ids, action, navigate=true) {
return (dispatch, getState) => { return (dispatch, getState) => {
const previous = new Set(getState().selection); const previous = new Set(getState().selection);
dispatch({ type: action, ids }); dispatch({ type: action, ids });
@ -56,11 +56,13 @@ export default function selectTorrent(ids, action) {
} }
}); });
const url_torrents = state.selection.slice(0, 3); if (navigate) {
if (url_torrents.length > 0) { const url_torrents = state.selection.slice(0, 3);
dispatch(push(`/torrents/${url_torrents}`)); if (url_torrents.length > 0) {
} else { dispatch(push(`/torrents/${url_torrents}`));
dispatch(push("/")); } else {
dispatch(push("/"));
}
} }
}; };
} }

View File

@ -158,7 +158,7 @@ class TorrentDetails extends Component {
componentWillUnmount() { componentWillUnmount() {
const { dispatch } = this.props; const { dispatch } = this.props;
dispatch(selectTorrent([], EXCLUSIVE)); dispatch(selectTorrent([], EXCLUSIVE, false));
} }
renderHeader(selection) { renderHeader(selection) {