Skip to content

Commit

Permalink
feat: disable reset achievements button if user is not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
Hachi-R committed Jan 3, 2025
1 parent 3efb142 commit cade56b
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Game } from "@types";
import * as styles from "./game-options-modal.css";
import { gameDetailsContext } from "@renderer/context";
import { DeleteGameModal } from "@renderer/pages/downloads/delete-game-modal";
import { useDownload, useToast } from "@renderer/hooks";
import { useDownload, useToast, useUserDetails } from "@renderer/hooks";
import { RemoveGameFromLibraryModal } from "./remove-from-library-modal";
import { ResetAchievementsModal } from "./reset-achievements-modal";
import { FileDirectoryIcon, FileIcon } from "@primer/octicons-react";
Expand Down Expand Up @@ -48,6 +48,8 @@ export function GameOptionsModal({
cancelDownload,
} = useDownload();

const { userDetails } = useUserDetails();

const hasAchievements =
(achievements?.filter((achievement) => achievement.unlocked).length ?? 0) >
0;
Expand Down Expand Up @@ -350,7 +352,12 @@ export function GameOptionsModal({
<Button
onClick={() => setShowResetAchievementsModal(true)}
theme="danger"
disabled={deleting || isDeletingAchievements || !hasAchievements}
disabled={
deleting ||
isDeletingAchievements ||
!hasAchievements ||
!userDetails
}
>
{t("reset_achievements")}
</Button>
Expand Down

0 comments on commit cade56b

Please sign in to comment.