Skip to content

Commit

Permalink
fix: what's new modal is disappearing after page load
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorGoryany committed Oct 3, 2024
1 parent 47106cb commit 47872d1
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 7 deletions.
120 changes: 120 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions src/components/WhatsNew/WhatsNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ const ModalOnEvent = dynamic(() => import('../ModalOnEvent'));

const WhatsNew = () => {
const locale = useLocale();
const utils = trpc.useContext();
const [iframeReady, setIframeReady] = useState(false);

const { data } = trpc.whatsnew.check.useQuery({
locale,
});
const { data } = trpc.whatsnew.check.useQuery(
{
locale,
},
{
staleTime: Infinity,
},
);

useEffect(() => {
if (data?.releaseNotesExists && data?.version && !data?.read && !data?.delayed) {
Expand All @@ -39,21 +45,21 @@ const WhatsNew = () => {
await markAsReadMutation.mutateAsync({
version: data.version,
});

utils.whatsnew.check.invalidate();
dispatchModalEvent(ModalEvent.WhatsNewModal)();
}
}, [markAsReadMutation, data]);
}, [data?.version, markAsReadMutation, utils.whatsnew.check]);

const markAsDelayedMutation = trpc.whatsnew.markAsDelayed.useMutation();
const onDelayClick = useCallback(async () => {
if (data?.version) {
await markAsDelayedMutation.mutateAsync({
version: data.version,
});

utils.whatsnew.check.invalidate();
dispatchModalEvent(ModalEvent.WhatsNewModal)();
}
}, [markAsDelayedMutation, data]);
}, [data?.version, markAsDelayedMutation, utils.whatsnew.check]);

return (
<ModalOnEvent event={ModalEvent.WhatsNewModal}>
Expand Down

0 comments on commit 47872d1

Please sign in to comment.