-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03a460c
commit 0589cf0
Showing
9 changed files
with
1,741 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Components/NewVersionAvailableHint/NewVersionAvailableHint.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from "react"; | ||
import { Tooltip } from "@skbkontur/react-ui"; | ||
import { useAppSelector } from "../../store/hooks"; | ||
import { UIState } from "../../store/selectors"; | ||
import Info from "@skbkontur/react-icons/Info"; | ||
|
||
export const NewVersionAvailableHint = () => { | ||
const { isNewFrontendVersionAvailable } = useAppSelector(UIState); | ||
|
||
return isNewFrontendVersionAvailable ? ( | ||
<div style={{ position: "fixed", bottom: "30px", right: "30px" }}> | ||
<Tooltip render={() => "New version available, please reload the page"}> | ||
<Info size={30} /> | ||
</Tooltip> | ||
</div> | ||
) : null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
export function register(onUpdate: () => void) { | ||
if ("serviceWorker" in navigator) { | ||
window.addEventListener("load", async () => { | ||
try { | ||
const registration = await navigator.serviceWorker.register("/service-worker.js"); | ||
|
||
setInterval(async () => { | ||
try { | ||
await registration.update(); | ||
} catch (error) { | ||
console.error("Error updating service worker:", error); | ||
} | ||
}, 1000 * 60); | ||
|
||
registration.onupdatefound = () => { | ||
const installingWorker = registration.installing; | ||
if (installingWorker) { | ||
installingWorker.onstatechange = () => { | ||
if ( | ||
installingWorker.state === "installed" && | ||
navigator.serviceWorker.controller | ||
) { | ||
onUpdate && onUpdate(); | ||
} | ||
}; | ||
} | ||
}; | ||
} catch (error) { | ||
console.error("Error during service worker registration:", error); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.