From 87a1a6788048bf7deb7533a895e14365a4806052 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Thu, 2 Jan 2025 03:09:42 +0100 Subject: [PATCH] Use static hide timeout for all reader setting previews 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 --- src/modules/reader/screens/Reader.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/reader/screens/Reader.tsx b/src/modules/reader/screens/Reader.tsx index 2e045ca727..76f1fae97d 100644 --- a/src/modules/reader/screens/Reader.tsx +++ b/src/modules/reader/screens/Reader.tsx @@ -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; @@ -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;