Skip to content

Commit

Permalink
feat: Clear playtime tracking per game
Browse files Browse the repository at this point in the history
  • Loading branch information
colin969 committed Mar 21, 2024
1 parent d79e0b2 commit fbf1ed5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 26 deletions.
48 changes: 24 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@fortawesome/fontawesome-svg-core": "1.2.36",
"@fortawesome/free-solid-svg-icons": "5.15.4",
"@fortawesome/react-fontawesome": "0.1.18",
"@fparchive/flashpoint-archive": "0.7.3",
"@fparchive/flashpoint-archive": "0.7.4",
"@types/react-virtualized": "^9.21.21",
"axios": "1.6.7",
"connected-react-router": "6.9.2",
Expand Down
7 changes: 7 additions & 0 deletions src/back/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,13 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
state.socketServer.broadcast(BackOut.CANCEL_DIALOG, dialogId);
});

state.socketServer.register(BackIn.CLEAR_PLAYTIME_TRACKING_BY_ID, async (event, gameId) => {
if (gameId !== '') {
await fpDatabase.clearPlaytimeTrackingById(gameId);
}
});


state.socketServer.register(BackIn.RUN_COMMAND, async (event, command, args = []) => {
// Find command
const c = state.registry.commands.get(command);
Expand Down
9 changes: 8 additions & 1 deletion src/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,14 @@ export class App extends React.Component<AppProps> {
});
});
}
}, { type: 'separator' }];
}, { type: 'separator' }, {
/* Clear Playtime Tracking */
label: strings.config.clearPlaytimeTracking,
enabled: !window.Shared.isBackRemote, // (Local "back" only)
click: () => {
window.Shared.back.send(BackIn.CLEAR_PLAYTIME_TRACKING_BY_ID, gameId);
}
}];

// Add editing mode fields
if (this.props.preferencesData.enableEditing) {
Expand Down
2 changes: 2 additions & 0 deletions src/shared/back/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export enum BackIn {
OPTIMIZE_DATABASE,
PRE_UPDATE_INFO,
CLEAR_PLAYTIME_TRACKING,
CLEAR_PLAYTIME_TRACKING_BY_ID,
KEEP_ALIVE,

// Dialogs
Expand Down Expand Up @@ -380,6 +381,7 @@ export type BackInTemplate = SocketTemplate<BackIn, {
[BackIn.OPTIMIZE_DATABASE]: () => void;
[BackIn.PRE_UPDATE_INFO]: (source: GameMetadataSource) => number;
[BackIn.CLEAR_PLAYTIME_TRACKING]: () => Promise<void>;
[BackIn.CLEAR_PLAYTIME_TRACKING_BY_ID]: (gameId: string) => Promise<void>;
[BackIn.KEEP_ALIVE]: () => void;

// Developer
Expand Down

0 comments on commit fbf1ed5

Please sign in to comment.