From 038272182a01f63b83ee9b006f61ba86b609657a Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 22 Oct 2023 09:15:02 +0100 Subject: [PATCH] add toast to warn about empty scores db --- src/store/playerScoresStore.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/store/playerScoresStore.ts b/src/store/playerScoresStore.ts index f9930ad..c8a59b0 100644 --- a/src/store/playerScoresStore.ts +++ b/src/store/playerScoresStore.ts @@ -3,6 +3,7 @@ import { ScoresaberPlayerScore } from "@/schemas/scoresaber/playerScore"; import { fetchAllScores, fetchScores } from "@/utils/scoresaber/api"; import moment from "moment"; +import { toast } from "react-toastify"; import { create } from "zustand"; import { createJSONStorage, persist } from "zustand/middleware"; import { useSettingsStore } from "./settingsStore"; @@ -161,15 +162,6 @@ export const usePlayerScoresStore = create()( } const players = usePlayerScoresStore.getState().players; - if (players.length == 0) { - const userId = useSettingsStore.getState().userId; - if (userId) { - console.log( - `Your profile was not found in the scores database, adding it...`, - ); - await usePlayerScoresStore.getState().addPlayer(userId); - } - } const friends = useSettingsStore.getState().friends; for (const friend of friends) { players.push({ @@ -181,6 +173,17 @@ export const usePlayerScoresStore = create()( } if (players.length == 0) { + toast.info( + "Scores database was empty, adding your profile and friends to it", + ); + + const userId = useSettingsStore.getState().userId; + if (userId) { + console.log( + `Your profile was not found in the scores database, adding it...`, + ); + await usePlayerScoresStore.getState().addPlayer(userId); + } for (const friend of friends) { console.log( `Friend ${friend.name} was not found in the scores database, adding them...`,