Added enableRandom
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user