Skip to content

Commit

Permalink
lowercase connectiviy
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatrakazas committed Nov 18, 2024
1 parent 74f0e6b commit 19acd83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/Layout/Navigation/ConnectionStatusIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import StatusContext from '../../../context/StatusContext';
import { FaXmark } from "react-icons/fa6";

const ConnectionStatusIcon = ({ size = 'normal', backgroundColor = 'dark' }) => {
const { Connectivity } = useContext(StatusContext);
const { connectivity } = useContext(StatusContext);
const { t } = useTranslation();

const quality = Connectivity.speed;
const quality = connectivity.speed;
const bars = Array.from({ length: 5 }, (_, i) => i < quality);
const barHeights = size === 'normal' ? [4, 8, 12, 16, 20] : [3, 6, 9, 12, 16];
const filledColor = backgroundColor === 'light' ? 'bg-primary dark:bg-white' : 'bg-white';
Expand Down
12 changes: 6 additions & 6 deletions src/context/StatusContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ interface Connectivity {
interface StatusContextValue {
isOnline: boolean | null; // Allow null for initial state
updateAvailable: boolean;
Connectivity: Connectivity;
connectivity: Connectivity;
updateOnlineStatus: (forceCheck?: boolean) => Promise<void>; // Only takes `forceCheck` as an optional parameter
}

const StatusContext = createContext<StatusContextValue>({
isOnline: null,
updateAvailable: false,
Connectivity: { navigatorOnline: null, Internet: null, speed: 0 },
connectivity: { navigatorOnline: null, Internet: null, speed: 0 },
updateOnlineStatus: async () => { }, // Default to a no-op async function
});

Expand Down Expand Up @@ -58,7 +58,7 @@ function getNavigatorOnlineStatus(): boolean {
export const StatusProvider = ({ children }: { children: React.ReactNode }) => {
const [isOnline, setIsOnline] = useState<boolean | null>(null);
const [updateAvailable, setUpdateAvailable] = useState(false);
const [Connectivity, setConnectivity] = useState<Connectivity>({
const [connectivity, setConnectivity] = useState<Connectivity>({
navigatorOnline: null,
Internet: null,
speed: 0,
Expand Down Expand Up @@ -178,8 +178,8 @@ export const StatusProvider = ({ children }: { children: React.ReactNode }) => {

useEffect(() => {
console.log('Online status:', isOnline);
console.log('Internet connection status:', Connectivity);
}, [isOnline, Connectivity]);
console.log('Internet connection status:', connectivity);
}, [isOnline, connectivity]);

navigator.serviceWorker.addEventListener('message', (event) => {
if (event.data && event.data.type === 'NEW_CONTENT_AVAILABLE') {
Expand All @@ -194,7 +194,7 @@ export const StatusProvider = ({ children }: { children: React.ReactNode }) => {
});

return (
<StatusContext.Provider value={{ isOnline, updateAvailable, Connectivity, updateOnlineStatus }}>
<StatusContext.Provider value={{ isOnline, updateAvailable, connectivity, updateOnlineStatus }}>
{children}
</StatusContext.Provider>
);
Expand Down

0 comments on commit 19acd83

Please sign in to comment.