feat: ensure unique splash text on schedule change (#554)

This commit is contained in:
Samuel Gunter
2025-03-10 18:57:54 -05:00
committed by GitHub
parent b1e98ca9d7
commit 9448072112

View File

@@ -66,11 +66,19 @@ export default function PopupMain(): JSX.Element {
}; };
useEffect(() => { useEffect(() => {
const randomIndex = Math.floor(Math.random() * splashText.length); setFunny(prevFunny => {
setFunny( // Ensure that the next splash text is not the same as the previous one
splashText[randomIndex] ?? 'If you are seeing this, something has gone horribly wrong behind the scenes.' 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 handleOpenOptions = async () => {
const url = chrome.runtime.getURL('/options.html'); const url = chrome.runtime.getURL('/options.html');