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

View File

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