Skip to content

Commit b355cd4

Browse files
committed
Perform soft page change on user consistency invalidation to show the error modal
1 parent 948082f commit b355cd4

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/app/services/history.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {createBrowserHistory} from "history";
2-
import {changePage} from "../state/actions";
2+
import {registerPageChange} from "../state/actions";
33

44
export const history = createBrowserHistory();
55

@@ -8,7 +8,7 @@ let previousPathname = window.location.pathname;
88
history.listen((location) => {
99
const nextPathname = location.pathname;
1010
if (previousPathname != nextPathname) {
11-
changePage(location.pathname);
11+
registerPageChange(location.pathname);
1212
previousPathname = nextPathname;
1313
}
1414
});

src/app/state/actions.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
AssignmentDTO,
3838
AuthenticationProvider,
3939
ChoiceDTO,
40+
EmailVerificationStatus,
4041
GameboardDTO,
4142
GlossaryTermDTO,
4243
IsaacQuestionPageDTO,
@@ -46,8 +47,7 @@ import {
4647
TestCaseDTO,
4748
UserGroupDTO,
4849
UserSummaryDTO,
49-
UserSummaryWithEmailAddressDTO,
50-
EmailVerificationStatus
50+
UserSummaryWithEmailAddressDTO
5151
} from "../../IsaacApiTypes";
5252
import {
5353
releaseAllConfirmationModal,
@@ -1711,8 +1711,11 @@ export const fetchConcepts = () => async (dispatch: Dispatch<Action>) => {
17111711

17121712

17131713
// SERVICE ACTIONS (w/o dispatch)
1714-
// Page change
17151714
export const changePage = (path: string) => {
1715+
history.push(path);
1716+
};
1717+
1718+
export const registerPageChange = (path: string) => {
17161719
store.dispatch({type: ACTION_TYPE.ROUTER_PAGE_CHANGE, path});
17171720
};
17181721

src/app/state/userConsistencyChecker.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {Dispatch, Middleware, MiddlewareAPI} from "redux";
22
import {RegisteredUserDTO} from "../../IsaacApiTypes";
33
import {ACTION_TYPE} from "../services/constants";
44
import {getUserId, setUserId} from "./userConsistencyCheckerCurrentUser";
5+
import {changePage} from "./actions";
56

67
// Generic log action:
78
// This is not imported from actions to avoid a circular dependency through store.
@@ -40,6 +41,7 @@ const setCurrentUser = (user: RegisteredUserDTO, api: MiddlewareAPI) => {
4041
if (setUserId(user._id)) {
4142
scheduleNextCheck(api);
4243
} else {
44+
// eslint-disable-next-line no-console
4345
console.error("Cannot perform user consistency checking!");
4446
const eventDetails = {
4547
type: "USER_CONSISTENCY_CHECKING_FAILED",
@@ -52,7 +54,7 @@ const setCurrentUser = (user: RegisteredUserDTO, api: MiddlewareAPI) => {
5254
const clearCurrentUser = () => {
5355
clearTimeout(timeoutHandle);
5456
setUserId(undefined);
55-
window.document.location.href = "/";
57+
changePage("/");
5658
};
5759

5860
export const userConsistencyCheckerMiddleware: Middleware = (api: MiddlewareAPI) => (next: Dispatch) => action => {

0 commit comments

Comments
 (0)