feat: ensure unique splash text on schedule change (#554)
This commit is contained in:
@@ -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');
|
||||||
|
|||||||
Reference in New Issue
Block a user