Public Access
feat(questions): list and restore removed games
Add a "Removed games" section on the questions page and an Undo toast after removing a manual game (#39).
This commit is contained in:
1 parent
c126592887
commit
84b16a2ca8
14 files changed
+280
-9
No files matched your search
@@ -8,10 +8,12 @@ import {Button} from '@/components/ui/button';
|
||||
import {Card} from '@/components/ui/card';
|
||||
import {Input} from '@/components/ui/input';
|
||||
import {Label} from '@/components/ui/label';
|
||||
import {hoursToMinutes, removeGame, toHours, updateManualGame} from '../utils/manualGames.js';
|
||||
import {hoursToMinutes, removeGame, restoreGame, toHours, updateManualGame} from '../utils/manualGames.js';
|
||||
import {MAX_PLATFORM_LENGTH} from '../utils/limits.js';
|
||||
import useUnsavedChanges, {discardChanges} from '../hooks/useUnsavedChanges.js';
|
||||
|
||||
const UNDO_MS = 8000;
|
||||
|
||||
/**
|
||||
* Platform and hours of a game added by hand, and removing it. Steam games get both from the sync.
|
||||
*
|
||||
@@ -54,8 +56,16 @@ export default function ManualGameCard({game, onSaved}) {
|
||||
toast.success(t('BACKLOG.SAVED'));
|
||||
});
|
||||
|
||||
const undoRemove = () => run(() => restoreGame(game.appid), () => {
|
||||
toast.success(t('REMOVED_GAMES.RESTORED'));
|
||||
navigate(`/library/${game.appid}`);
|
||||
});
|
||||
|
||||
const remove = () => run(() => removeGame(game.appid), () => {
|
||||
toast.success(t('MANUAL_GAME.REMOVED'));
|
||||
toast.success(t('MANUAL_GAME.REMOVED'), {
|
||||
duration: UNDO_MS,
|
||||
action: {label: t('MANUAL_GAME.UNDO'), onClick: undoRemove},
|
||||
});
|
||||
// The game is gone, so are its unsaved edits on this page.
|
||||
discardChanges();
|
||||
navigate('/library', {replace: true});
|
||||
|
||||
Reference in new issue
Block a user