Skip to content

Commit

Permalink
fix: show error snackbars when non-LoginError exceptions occur duri…
Browse files Browse the repository at this point in the history
…ng login process
  • Loading branch information
UNIDY2002 committed Nov 4, 2024
1 parent 169161d commit 59c56f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 2 additions & 1 deletion apps/thu-info-app/src/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
CampusCardState,
defaultCampusCard,
} from "./slices/campusCard";
import { LoginError } from "@thu-info/lib/src/utils/error";

export const helper = new InfoHelper();

Expand Down Expand Up @@ -258,7 +259,7 @@ export const navigationRef = createNavigationContainerRef<{
}>();

helper.loginErrorHook = (e) => {
if (navigationRef.isReady()) {
if (e instanceof LoginError && navigationRef.isReady()) {
navigationRef.navigate("Login");
}
setTimeout(
Expand Down
4 changes: 1 addition & 3 deletions packages/thu-info-lib/src/lib/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ export const login = async (
await roam(helper, "id", "10000ea055dd8d81d09d5a1ba55d39ad");
outstandingLoginPromise = undefined;
})().then(resolve, (e: any) => {
if (e instanceof LoginError) {
helper.loginErrorHook && helper.loginErrorHook(e);
}
helper.loginErrorHook && helper.loginErrorHook(e);
outstandingLoginPromise = undefined;
reject(e);
});
Expand Down

0 comments on commit 59c56f3

Please sign in to comment.