Skip to content

Commit

Permalink
Use static hide timeout for all reader setting previews
Browse files Browse the repository at this point in the history
The default timeout of "notistack" is 5s by default, however, this makes it more clear and also prevents any behaviour changes in the future, in case the default timeout gets changed
  • Loading branch information
schroda committed Jan 2, 2025
1 parent af8ada9 commit 87a1a67
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/modules/reader/screens/Reader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,14 @@ const BaseReader = ({
return;
}

const HIDE_PREVIEW_TIMEOUT = 5000;

const didReadingModeChange = JSON.stringify(readingMode) !== JSON.stringify(previousReadingMode.current);
const showReadingModePreview = shouldShowReadingModePreview && didReadingModeChange;
if (showReadingModePreview) {
makeToast(t(READING_MODE_VALUE_TO_DISPLAY_DATA[readingMode.value].title as TranslationKey));
makeToast(t(READING_MODE_VALUE_TO_DISPLAY_DATA[readingMode.value].title as TranslationKey), {
autoHideDuration: HIDE_PREVIEW_TIMEOUT,
});
}
previousReadingMode.current = readingMode;

Expand All @@ -314,7 +318,7 @@ const BaseReader = ({
if (showTapZoneLayoutPreview) {
setShowPreview(true);
if (isInitialPreview.current) {
setTimeout(() => setShowPreview(false), 5000);
setTimeout(() => setShowPreview(false), HIDE_PREVIEW_TIMEOUT);
}
}
previousTapZoneLayout.current = tapZoneLayout;
Expand Down

0 comments on commit 87a1a67

Please sign in to comment.