docs(nx-dev): use localstorage for livestream banner (#28880)

This commit is contained in:
Benjamin Cabanes 2024-11-11 10:42:27 -05:00 committed by GitHub
parent 258a2566f1
commit cc251e4378
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,12 +11,12 @@ import {
} from '@heroicons/react/24/outline';
export function LiveStreamNotifier(): ReactElement | null {
const [isMounted, setIsMounted] = useState(false);
const [isVisible, setIsVisible] = useState<boolean>(true);
useEffect(() => {
const isClosedSession = sessionStorage.getItem(
'live-stream-notifier-closed'
);
setIsMounted(true);
const isClosedSession = localStorage.getItem('live-stream-notifier-closed');
if (isClosedSession === 'true') {
setIsVisible(false);
}
@ -25,10 +25,10 @@ export function LiveStreamNotifier(): ReactElement | null {
const closeNotifier = (e: React.MouseEvent) => {
e.stopPropagation();
setIsVisible(false);
sessionStorage.setItem('live-stream-notifier-closed', 'true');
localStorage.setItem('live-stream-notifier-closed', 'true');
};
if (!isVisible) return null;
if (!isMounted || !isVisible) return null;
return (
<motion.div