Skip to content

Commit 14218f3

Browse files
authored
Merge pull request #179 from 0x416c616e/wv-2636-redirect-if-logged-out
WV-2636 follow-up: raise login-redirect error threshold to 200 for mobile
2 parents a87d944 + ffca660 commit 14218f3

4 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/js/pages/SystemSettings/SystemSettings.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const SystemSettings = () => {
2525
const [personIdsList, setPersonIdsList] = useState([]);
2626

2727
const personListRetrieveResults = useFetchData(['person-list-retrieve'], {}, METHOD.GET);
28-
const API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD = 30;
28+
const API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD = 200;
2929
useRedirectToLoginIfLoggedOut(personListRetrieveResults, API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD); //or maybe taskDefinitionListRetrieveResults or taskGroupListRetrieveResults or taskStatusListRetrieveResults?
3030

3131
useEffect(() => {

src/js/pages/Tasks.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const Tasks = () => {
7676
}
7777
}, [teamListRetrieveResults]);
7878

79-
const API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD = 30;
79+
const API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD = 200;
8080
useRedirectToLoginIfLoggedOut(teamListRetrieveResults, API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD);
8181

8282
useEffect(() => {

src/js/pages/Teams.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const Teams = () => {
4646
}, [personListRetrieveResults, allPeopleCache, dispatch]);
4747

4848
const teamListRetrieveResults = useFetchData(['team-list-retrieve'], {}, METHOD.GET);
49-
const API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD = 50;
49+
const API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD = 200;
5050
useRedirectToLoginIfLoggedOut(teamListRetrieveResults, API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD);
5151

5252

src/js/utils/useRedirectToLoginIfLoggedOut.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import { useConnectAppContext } from '../contexts/ConnectAppContext';
66
// a logged-out session by counting consecutive failures on endpoints that
77
// require an active login. The threshold is intentionally high (50) because
88
// occasional errors happen even when logged in; 15 was too trigger-happy.
9-
// const API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD = 50;
10-
// Teams = 50, other pages make fewer requests and are set to 30, shouldn't be less than about 20.
11-
// Number might have to change in the future if/when the back-end requests etc are changed.
12-
// Now it's an argument rather than a constant.
9+
// API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD was originall 30-50, and that worked for desktop tests,
10+
// but was too trigger-happy on mobile, detecting subsequent errors of a logged in user as proof of being logged out
11+
// now it's 200 to be on the safe side
1312

1413
const useRedirectToLoginIfLoggedOut = (retrieveResults, retrieveErrorsThreshold) => {
1514
const API_RETRIEVE_ERRORS_IN_A_ROW_THRESHOLD = retrieveErrorsThreshold;
@@ -34,7 +33,7 @@ const useRedirectToLoginIfLoggedOut = (retrieveResults, retrieveErrorsThreshold)
3433
}
3534
} else if (retrieveResults.isSuccess === true && getAppContextValue('apiRetrieveErrorsInARowCount') !== 0) {
3635
setAppContextValue('apiRetrieveErrorsInARowCount', 0);
37-
// console.log(`apiRetrieveErrorsInARowCount: ${getAppContextValue('apiRetrieveErrorsInARowCount')}`);
36+
console.log(`apiRetrieveErrorsInARowCount: ${getAppContextValue('apiRetrieveErrorsInARowCount')}`);
3837
}
3938
}, [retrieveResults]); // eslint-disable-line react-hooks/exhaustive-deps
4039
};

0 commit comments

Comments
 (0)