|
|
|
@ -1,5 +1,4 @@
@@ -1,5 +1,4 @@
|
|
|
|
|
import { Redirect, Route, Switch } from "react-router-dom"; |
|
|
|
|
import { useRegisterSW } from "virtual:pwa-register/react"; |
|
|
|
|
import { BookmarkContextProvider } from "@/state/bookmark"; |
|
|
|
|
import { WatchedContextProvider } from "@/state/watched"; |
|
|
|
|
|
|
|
|
@ -13,66 +12,12 @@ import { VideoTesterView } from "@/views/developer/VideoTesterView";
@@ -13,66 +12,12 @@ import { VideoTesterView } from "@/views/developer/VideoTesterView";
|
|
|
|
|
import { ProviderTesterView } from "@/views/developer/ProviderTesterView"; |
|
|
|
|
import { EmbedTesterView } from "@/views/developer/EmbedTesterView"; |
|
|
|
|
|
|
|
|
|
function ReloadPrompt() { |
|
|
|
|
const { |
|
|
|
|
offlineReady: [offlineReady, setOfflineReady], |
|
|
|
|
needRefresh: [needRefresh, setNeedRefresh], |
|
|
|
|
updateServiceWorker, |
|
|
|
|
} = useRegisterSW({ |
|
|
|
|
onRegistered(r) { |
|
|
|
|
// eslint-disable-next-line prefer-template
|
|
|
|
|
console.log("SW Registered: " + r); |
|
|
|
|
}, |
|
|
|
|
onRegisterError(error) { |
|
|
|
|
console.log("SW registration error", error); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const close = () => { |
|
|
|
|
setOfflineReady(false); |
|
|
|
|
setNeedRefresh(false); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div className="ReloadPrompt-container"> |
|
|
|
|
{(offlineReady || needRefresh) && ( |
|
|
|
|
<div className="ReloadPrompt-toast"> |
|
|
|
|
<div className="ReloadPrompt-message"> |
|
|
|
|
{offlineReady ? ( |
|
|
|
|
<span>App ready to work offline</span> |
|
|
|
|
) : ( |
|
|
|
|
<span> |
|
|
|
|
New content available, click on reload button to update. |
|
|
|
|
</span> |
|
|
|
|
)} |
|
|
|
|
</div> |
|
|
|
|
{needRefresh && ( |
|
|
|
|
<button |
|
|
|
|
type="button" |
|
|
|
|
className="ReloadPrompt-toast-button" |
|
|
|
|
onClick={() => updateServiceWorker(true)} |
|
|
|
|
> |
|
|
|
|
Reload |
|
|
|
|
</button> |
|
|
|
|
)} |
|
|
|
|
<button |
|
|
|
|
type="button" |
|
|
|
|
className="ReloadPrompt-toast-button" |
|
|
|
|
onClick={() => close()} |
|
|
|
|
> |
|
|
|
|
Close |
|
|
|
|
</button> |
|
|
|
|
</div> |
|
|
|
|
)} |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
// TODO add "you are offline" status bar
|
|
|
|
|
|
|
|
|
|
function App() { |
|
|
|
|
return ( |
|
|
|
|
<WatchedContextProvider> |
|
|
|
|
<BookmarkContextProvider> |
|
|
|
|
<ReloadPrompt /> |
|
|
|
|
<Switch> |
|
|
|
|
{/* functional routes */} |
|
|
|
|
<Route exact path="/v2-migration" component={V2MigrationView} /> |
|
|
|
|