All of the mid-session and step-up auth work
This commit is contained in:
parent
1f31e0f1f8
commit
562bdd00f1
1 changed files with 11437 additions and 1212 deletions
20
clients/web/src/utils/browserTabVisibility.ts
Normal file
20
clients/web/src/utils/browserTabVisibility.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/** True when this browser tab is the foreground tab (Page Visibility API). */
|
||||
export function isBrowserTabVisible(): boolean {
|
||||
return (
|
||||
typeof document !== "undefined" && document.visibilityState === "visible"
|
||||
);
|
||||
}
|
||||
|
||||
/** Subscribe to this browser tab becoming visible. Returns an unsubscribe function. */
|
||||
export function onBrowserTabVisible(callback: () => void): () => void {
|
||||
if (typeof document === "undefined") {
|
||||
return () => {};
|
||||
}
|
||||
const handler = (): void => {
|
||||
if (document.visibilityState === "visible") {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
document.addEventListener("visibilitychange", handler);
|
||||
return () => document.removeEventListener("visibilitychange", handler);
|
||||
}
|
||||
Loading…
Reference in a new issue