Skip to content

refactor: Cancels the delayed handling of jump actions. #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ui/src/pages/Users/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ const Index: React.FC = () => {
}

login(params)
.then((res) => {
passwordCaptcha.close();
.then(async (res) => {
await passwordCaptcha.close();
updateUser(res);
const userStat = guard.deriveLoginState();
if (userStat.isNotActivated) {
Expand Down
60 changes: 27 additions & 33 deletions ui/src/utils/floppyNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,42 +94,36 @@ export interface NavigateConfig {
}
const navigate = (to: string | number, config: NavigateConfig = {}) => {
let { handler = 'href' } = config;
/**
* Note: Synchronised navigation can result in asynchronous actions such as page animations and state modifications not being completed.
*/
setTimeout(() => {
if (to && typeof to === 'string') {
if (equalToCurrentHref(to)) {
return;
}
/**
* 1. Blocking redirection of two login pages
* 2. Auto storage login redirect
* Note: The or judgement cannot be missing here, both jumps will be used
*/
if (to === RouteAlias.login || to === getLoginUrl()) {
storageLoginRedirect();
}

if (!isRoutableLink(to) && handler !== 'href' && handler !== 'replace') {
handler = 'href';
}
if (handler === 'href' && config.options?.replace) {
handler = 'replace';
}
if (handler === 'href') {
window.location.href = to;
} else if (handler === 'replace') {
window.location.replace(to);
} else if (typeof handler === 'function') {
handler(to, config.options);
}
if (to && typeof to === 'string') {
if (equalToCurrentHref(to)) {
return;
}
/**
* 1. Blocking redirection of two login pages
* 2. Auto storage login redirect
* Note: The or judgement cannot be missing here, both jumps will be used
*/
if (to === RouteAlias.login || to === getLoginUrl()) {
storageLoginRedirect();
}

if (typeof to === 'number' && typeof handler === 'function') {
handler(to);
if (!isRoutableLink(to) && handler !== 'href' && handler !== 'replace') {
handler = 'href';
}
});
if (handler === 'href' && config.options?.replace) {
handler = 'replace';
}
if (handler === 'href') {
window.location.href = to;
} else if (handler === 'replace') {
window.location.replace(to);
} else if (typeof handler === 'function') {
handler(to, config.options);
}
}
if (typeof to === 'number' && typeof handler === 'function') {
handler(to);
}
};

/**
Expand Down