import { useEffect } from 'react';
import { exitViewerFullscreen } from '@/pages/viewer/utils/viewerFullscreen';

type Options = {
  enabled: boolean;
};

/** Leaves browser fullscreen when the viewer route unmounts. */
export function useBrowserFullscreen({ enabled }: Options) {
  useEffect(() => {
    if (!enabled) return;
    return () => {
      exitViewerFullscreen();
    };
  }, [enabled]);
}
