Added enableRandom

This commit is contained in:
Sean Edmunds
2024-12-20 13:49:54 -06:00
parent 33813a34fb
commit 9c22106216
2 changed files with 61 additions and 25 deletions

View File

@@ -42,8 +42,13 @@ function App() {
const temp = data.find((t: any) => t.name === themeName);
setTheme(temp);
} else {
const index = Math.floor(Math.random() * data.length);
setTheme(data[index]);
let enabled = data.filter((t: any) => t.randomEnabled);
if (enabled.length === 0) {
setTheme(data[0]);
} else {
const index = Math.floor(Math.random() * enabled.length);
setTheme(enabled[index]);
}
}
}
}, [isFetched, themeName]);