From 94480721124e052426c1f3236e8605c7088df79c Mon Sep 17 00:00:00 2001 From: Samuel Gunter <29130894+Samathingamajig@users.noreply.github.com> Date: Mon, 10 Mar 2025 18:57:54 -0500 Subject: [PATCH] feat: ensure unique splash text on schedule change (#554) --- src/views/components/PopupMain.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/views/components/PopupMain.tsx b/src/views/components/PopupMain.tsx index 808f9475..1ee5864e 100644 --- a/src/views/components/PopupMain.tsx +++ b/src/views/components/PopupMain.tsx @@ -66,11 +66,19 @@ export default function PopupMain(): JSX.Element { }; useEffect(() => { - const randomIndex = Math.floor(Math.random() * splashText.length); - setFunny( - splashText[randomIndex] ?? 'If you are seeing this, something has gone horribly wrong behind the scenes.' - ); - }, []); + setFunny(prevFunny => { + // Ensure that the next splash text is not the same as the previous one + const splashTextWithoutCurrent = splashText.filter(text => text !== prevFunny); + const randomIndex = Math.floor(Math.random() * splashTextWithoutCurrent.length); + + return ( + splashTextWithoutCurrent[randomIndex] ?? + 'If you are seeing this, something has gone horribly wrong behind the scenes.' + ); + }); + + // Generate a new splash text every time the active schedule changes + }, [activeSchedule.id]); const handleOpenOptions = async () => { const url = chrome.runtime.getURL('/options.html');