Skip to content

Commit

Permalink
docs(nx-dev): use localstorage for livestream banner (#28880)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcabanes authored Nov 11, 2024
1 parent 258a256 commit cc251e4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nx-dev/ui-common/src/lib/live-stream-notifier.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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
Expand Down

0 comments on commit cc251e4

Please sign in to comment.