fix release notes not displayed on version change

This commit is contained in:
jeffvli
2026-01-04 14:24:34 -08:00
parent 7ae0aa198e
commit 834412ad31
+30 -20
View File
@@ -130,7 +130,12 @@ const ReleaseNotesContent = ({ onDismiss, version }: ReleaseNotesContentProps) =
height: '400px', height: '400px',
}} }}
> >
<div dangerouslySetInnerHTML={{ __html: sanitizedHtml }} /> <Text
dangerouslySetInnerHTML={{ __html: sanitizedHtml }}
fw={400}
lh="1.5"
size="md"
/>
</ScrollArea> </ScrollArea>
<Group justify="flex-end"> <Group justify="flex-end">
<Button <Button
@@ -151,11 +156,13 @@ const ReleaseNotesContent = ({ onDismiss, version }: ReleaseNotesContentProps) =
); );
}; };
const WAIT_FOR_LOCAL_STORAGE = 1000 * 2;
export const ReleaseNotesModal = () => { export const ReleaseNotesModal = () => {
const { version } = packageJson; const { version } = packageJson;
const { t } = useTranslation(); const { t } = useTranslation();
const [value, setValue] = useLocalStorage({ key: 'version' }); const [, setValue] = useLocalStorage({ key: 'version' });
const handleDismiss = useCallback(() => { const handleDismiss = useCallback(() => {
setValue(version); setValue(version);
@@ -163,25 +170,28 @@ export const ReleaseNotesModal = () => {
}, [setValue, version]); }, [setValue, version]);
useEffect(() => { useEffect(() => {
// If value is undefined, set it to current version but don't show modal const timeoutId = setTimeout(() => {
if (value === undefined) { const valueFromLocalStorage = localStorage.getItem('version');
setValue(version); const versionString = `"${version}"`;
return;
}
// Only show modal if the stored version is different from current version // Only show modal if the stored version is different from current version
if (value !== version) { if (valueFromLocalStorage !== versionString) {
openModal({ openModal({
children: <ReleaseNotesContent onDismiss={handleDismiss} version={version} />, children: <ReleaseNotesContent onDismiss={handleDismiss} version={version} />,
onClose: handleDismiss, onClose: handleDismiss,
size: 'xl', size: 'xl',
title: t('common.newVersion', { title: t('common.newVersion', {
postProcess: 'sentenceCase', postProcess: 'sentenceCase',
version, version,
}) as string, }) as string,
}); });
} }
}, [handleDismiss, value, version, t, setValue]); }, WAIT_FOR_LOCAL_STORAGE);
return () => {
clearTimeout(timeoutId);
};
}, [handleDismiss, t, version]);
return null; return null;
}; };