Skip to content

Commit

Permalink
show offline banner base on useNavigatorOnLine hook
Browse files Browse the repository at this point in the history
  • Loading branch information
poulch committed Jul 30, 2024
1 parent 9b0b3c3 commit ed353d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/TopWarning/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useNavigatorOnLine } from "@dashboard/hooks/useNavigatorOnLine";
import React from "react";
import { useRegisterSW } from "virtual:pwa-register/react";

Expand All @@ -7,10 +8,11 @@ import { YouAreOffline } from "./YouAreOffline";
export const TopWarning = () => {
const {
needRefresh: [needRefresh],
offlineReady: [offlineReady],
} = useRegisterSW();

if (offlineReady) {
const isOnline = useNavigatorOnLine();

if (!isOnline) {
return <YouAreOffline />;
}

Expand Down

0 comments on commit ed353d4

Please sign in to comment.