1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-23 00:03:33 +00:00
bazarr/frontend/src/contexts/Online.ts

29 lines
631 B
TypeScript
Raw Normal View History

2022-05-31 15:49:04 +00:00
import { createContext, useContext } from "react";
const OnlineContext = createContext<{
online: boolean;
setOnline: (online: boolean) => void;
} | null>(null);
export function useIsOnline() {
const context = useContext(OnlineContext);
if (context === null) {
throw new Error("useIsOnline must be used within a OnlineProvider");
}
return context.online;
}
export function useSetOnline() {
const context = useContext(OnlineContext);
if (context === null) {
throw new Error("useSetOnline must be used within a OnlineProvider");
}
return context.setOnline;
}
export default OnlineContext.Provider;