Skip to content

Commit 2af3796

Browse files
allinoxVedeler
andauthored
Turn off A2 actor sync in AT22 (#2222)
* Turn off A2 actor sync in AT22 * track timeout and clear on unmount --------- Co-authored-by: Vedeler <acn-avede@ai-dev.no>
1 parent 3b32984 commit 2af3796

4 files changed

Lines changed: 15 additions & 7 deletions

File tree

backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI/appsettings.AT22.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"EnableAddSelfToSystemuser": true,
5656
"EnableDialogportenDialogLookup": false,
5757
"UseConnectionsForAgentSystemuser": true,
58-
"EnableMaskinportenAdministration": true
58+
"EnableMaskinportenAdministration": true,
59+
"RouteChangeReporteeViaAltinn2": false
5960
}
6061
}

backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@
5959
"EnableAddSelfToSystemuser": true,
6060
"EnableDialogportenDialogLookup": true,
6161
"EnableMaskinportenAdministration": true,
62-
"RouteChangeReporteeViaAltinn2": true
62+
"RouteChangeReporteeViaAltinn2": false
6363
}
6464
}

src/components/ReloadAlert/ReloadAlert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import classes from './ReloadAlert.module.css';
88
export const ReloadAlert = () => {
99
const { t } = useTranslation();
1010

11-
const displayAlert = useCookieListener('AltinnPartyId');
11+
const displayAlert = useCookieListener('AltinnPartyId', 2000, 2000);
1212

1313
return (
1414
displayAlert && (

src/resources/Cookie/CookieMethods.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,30 @@ export function getCookie(cname: string) {
2020
* Detects changes in a given cookie by polling it with the given interval
2121
* @param cookieName The name of the cookie to be checked
2222
* @param interval The interval in which to poll the cookie (given in milliseconds)
23+
* @param delayResponse The delay in milliseconds before signalling that the cookie has changed. Defaults to 0ms (no delay).
2324
* @returns `true` if the cookie has been changed from it's original value, `false` otherwise.
2425
*/
25-
export const useCookieListener = (cookieName: string, interval = 2000) => {
26+
export const useCookieListener = (cookieName: string, interval = 2000, delayResponse = 0) => {
2627
const [cookieValue, setCookieValue] = useState(getCookie(cookieName));
2728
const [cookieChanged, setCookieChanged] = useState(false);
2829

2930
useEffect(() => {
31+
let delayTimeout: ReturnType<typeof setTimeout> | undefined;
32+
3033
const checkCookie = setInterval(() => {
3134
const currentCookie = getCookie(cookieName);
3235
if (currentCookie !== cookieValue) {
3336
setCookieValue(currentCookie);
34-
setCookieChanged(true);
37+
clearTimeout(delayTimeout);
38+
delayTimeout = setTimeout(() => setCookieChanged(true), delayResponse);
3539
}
3640
}, interval); // Check every interval
3741

38-
return () => clearInterval(checkCookie);
39-
}, [cookieName, interval]);
42+
return () => {
43+
clearInterval(checkCookie);
44+
clearTimeout(delayTimeout);
45+
};
46+
}, [cookieName, interval, delayResponse]);
4047

4148
return cookieChanged;
4249
};

0 commit comments

Comments
 (0)