Improve 404 handling
This commit is contained in:
parent
869713d236
commit
5861a54dfc
File diff suppressed because one or more lines are too long
@ -17,11 +17,7 @@ export default class Editable extends PureComponent {
|
||||
// eslint-disable-next-line react/no-did-update-set-state
|
||||
this.updateInputWidth(this.props.value);
|
||||
this.inputEl.current.focus();
|
||||
}
|
||||
}
|
||||
|
||||
getSnapshotBeforeUpdate(prevProps) {
|
||||
if (this.state.editing && prevProps.value !== this.props.value) {
|
||||
} else if (this.state.editing && prevProps.value !== this.props.value) {
|
||||
this.updateInputWidth(this.props.value);
|
||||
}
|
||||
}
|
||||
|
@ -25,25 +25,47 @@ function loadState({ store }, env) {
|
||||
data: env.servers
|
||||
});
|
||||
|
||||
if (!store.getState().router.route) {
|
||||
const tab = Cookie.get('tab');
|
||||
if (tab) {
|
||||
const [server, name = null] = tab.split(/;(.+)/);
|
||||
const { router } = store.getState();
|
||||
|
||||
if (!router.route || router.route === 'chat') {
|
||||
const tabs = [];
|
||||
|
||||
if (router.route === 'chat') {
|
||||
tabs.push(router.params);
|
||||
}
|
||||
|
||||
const cookie = Cookie.get('tab');
|
||||
if (cookie) {
|
||||
const [server, name = null] = cookie.split(/;(.+)/);
|
||||
tabs.push({
|
||||
server,
|
||||
name
|
||||
});
|
||||
}
|
||||
|
||||
let found = false;
|
||||
let i = 0;
|
||||
|
||||
while (!found) {
|
||||
const tab = tabs[i];
|
||||
i++;
|
||||
|
||||
if (
|
||||
name &&
|
||||
tab.name &&
|
||||
find(
|
||||
env.channels,
|
||||
chan => chan.server === server && chan.name === name
|
||||
chan => chan.server === tab.server && chan.name === tab.name
|
||||
)
|
||||
) {
|
||||
store.dispatch(select(server, name, true));
|
||||
} else if (find(env.servers, srv => srv.host === server)) {
|
||||
store.dispatch(select(server, null, true));
|
||||
} else {
|
||||
store.dispatch(updateSelection());
|
||||
found = true;
|
||||
store.dispatch(select(tab.server, tab.name, true));
|
||||
} else if (find(env.servers, srv => srv.host === tab.server)) {
|
||||
found = true;
|
||||
store.dispatch(select(tab.server, null, true));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
store.dispatch(updateSelection());
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,10 @@ export function updateSelection() {
|
||||
|
||||
if (serverAddrs.length === 0) {
|
||||
dispatch(replace('/connect'));
|
||||
} else if (history.length > 0) {
|
||||
} else if (
|
||||
history.length > 0 &&
|
||||
history[history.length - 1] !== state.tab.selected
|
||||
) {
|
||||
const tab = history[history.length - 1];
|
||||
dispatch(select(tab.server, tab.name, true));
|
||||
} else if (servers[server]) {
|
||||
|
Loading…
Reference in New Issue
Block a user