Use replace in updateSelection

This commit is contained in:
Ken-Håvard Lieng 2017-05-15 06:27:30 +02:00
parent a4d40bef39
commit ff7c563b61
2 changed files with 26 additions and 25 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,12 @@
import * as actions from '../actions';
import { push, replace } from '../util/router';
export function select(server, name) {
export function select(server, name, doReplace) {
const navigate = doReplace ? replace : push;
if (name) {
return push(`/${server}/${encodeURIComponent(name)}`);
return navigate(`/${server}/${encodeURIComponent(name)}`);
}
return push(`/${server}`);
return navigate(`/${server}`);
}
export function updateSelection() {
@ -19,11 +20,11 @@ export function updateSelection() {
dispatch(replace('/connect'));
} else if (history.size > 0) {
const tab = history.last();
dispatch(select(tab.server, tab.name));
dispatch(select(tab.server, tab.name, true));
} else if (servers.has(server)) {
dispatch(select(server));
dispatch(select(server, null, true));
} else {
dispatch(replace('/'));
dispatch(select(servers.keySeq().first(), null, true));
}
};
}