mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-09 13:44:29 +08:00
checking if snapshot exists
updating random theme list if its empty closes #3248
This commit is contained in:
parent
f2d9d37b3e
commit
fb539ddd19
2 changed files with 7 additions and 4 deletions
|
|
@ -197,6 +197,7 @@ export function clearPreview(applyTheme = true): void {
|
|||
let themesList: string[] = [];
|
||||
|
||||
async function changeThemeList(): Promise<void> {
|
||||
if (!DB.getSnapshot()) return;
|
||||
const themes = await Misc.getThemesList();
|
||||
if (Config.randomTheme === "fav" && Config.favThemes.length > 0) {
|
||||
themesList = Config.favThemes;
|
||||
|
|
@ -219,9 +220,11 @@ async function changeThemeList(): Promise<void> {
|
|||
randomThemeIndex = 0;
|
||||
}
|
||||
|
||||
export function randomizeTheme(): void {
|
||||
//! setting randomThemeIndex to 0 everytime randomizeTheme is called
|
||||
|
||||
export async function randomizeTheme(): Promise<void> {
|
||||
if (themesList.length === 0) {
|
||||
await changeThemeList();
|
||||
if (themesList.length === 0) return;
|
||||
}
|
||||
const randomTheme = themesList[randomThemeIndex];
|
||||
randomThemeIndex++;
|
||||
|
||||
|
|
|
|||
|
|
@ -2951,7 +2951,7 @@ export const defaultCommands: MonkeyTypes.CommandsGroup = {
|
|||
id: "randomizeTheme",
|
||||
display: "Next random theme",
|
||||
icon: "fa-random",
|
||||
exec: (): void => ThemeController.randomizeTheme(),
|
||||
exec: (): Promise<void> => ThemeController.randomizeTheme(),
|
||||
available: (): boolean => {
|
||||
return Config.randomTheme !== "off";
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue