mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-05-12 21:40:45 +00:00
cleanup
This commit is contained in:
parent
5686019587
commit
42579ce297
2 changed files with 13 additions and 10 deletions
|
|
@ -3,17 +3,13 @@
|
||||||
import { createContext } from 'react';
|
import { createContext } from 'react';
|
||||||
|
|
||||||
export type FullscreenContextValue = readonly [
|
export type FullscreenContextValue = readonly [
|
||||||
boolean,
|
fullscreen: boolean,
|
||||||
() => Promise<void> | void,
|
requestFullscreen: () => Promise<void> | void,
|
||||||
() => void,
|
exitFullscreen: () => void,
|
||||||
() => void,
|
toggleFullscreen: () => void,
|
||||||
];
|
];
|
||||||
|
|
||||||
const noop = () => undefined;
|
const FullscreenContext = createContext<FullscreenContextValue | null>(null);
|
||||||
|
|
||||||
const defaultValue: FullscreenContextValue = [false, noop, noop, noop];
|
|
||||||
|
|
||||||
const FullscreenContext = createContext<FullscreenContextValue>(defaultValue);
|
|
||||||
|
|
||||||
FullscreenContext.displayName = 'FullscreenContext';
|
FullscreenContext.displayName = 'FullscreenContext';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,13 @@
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import FullscreenContext from './FullscreenContext';
|
import FullscreenContext from './FullscreenContext';
|
||||||
|
|
||||||
const useFullscreen = () => useContext(FullscreenContext);
|
const useFullscreen = () => {
|
||||||
|
const value = useContext(FullscreenContext);
|
||||||
|
if (value === null) {
|
||||||
|
throw new Error('useFullscreen must be used inside FullscreenProvider');
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
export default useFullscreen;
|
export default useFullscreen;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue