feat: implement reset game achievements functionality

This commit is contained in:
Hachi-R
2024-12-17 13:15:55 -03:00
parent 47a5f4d327
commit ac6eb247df
6 changed files with 65 additions and 5 deletions

View File

@@ -105,7 +105,7 @@ declare global {
) => void
) => () => Electron.IpcRenderer;
onLibraryBatchComplete: (cb: () => void) => () => Electron.IpcRenderer;
resetGameAchievements: (gameId: number) => Promise<void>;
/* User preferences */
getUserPreferences: () => Promise<UserPreferences | null>;
updateUserPreferences: (

View File

@@ -122,6 +122,11 @@ export function GameOptionsModal({
const shouldShowWinePrefixConfiguration =
window.electron.platform === "linux";
const handleResetAchievements = async () => {
await window.electron.resetGameAchievements(game.id);
updateGame();
};
return (
<>
<DeleteGameModal
@@ -140,7 +145,7 @@ export function GameOptionsModal({
<ResetAchievementsModal
visible={showResetAchievementsModal}
onClose={() => setShowResetAchievementsModal(false)}
// resetAchievements={handleResetAchievements}
resetAchievements={handleResetAchievements}
game={game}
/>

View File

@@ -7,19 +7,19 @@ interface ResetAchievementsModalProps {
visible: boolean;
game: Game;
onClose: () => void;
// resetAchievements: () => Promise<void>;
resetAchievements: () => Promise<void>;
}
export function ResetAchievementsModal({
onClose,
game,
visible,
// resetAchievements,
resetAchievements,
}: ResetAchievementsModalProps) {
const { t } = useTranslation("game_details");
const handleResetAchievements = async () => {
// await resetAchievements();
await resetAchievements();
onClose();
};