From fbf1ed5d53e8db31c2cdb443a23fe8a70f532a2b Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 21 Mar 2024 12:16:50 +0000 Subject: [PATCH] feat: Clear playtime tracking per game --- package-lock.json | 48 ++++++++++++++++++++-------------------- package.json | 2 +- src/back/responses.ts | 7 ++++++ src/renderer/app.tsx | 9 +++++++- src/shared/back/types.ts | 2 ++ 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index ca112b71e..89f05c433 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,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", @@ -991,24 +991,24 @@ } }, "node_modules/@fparchive/flashpoint-archive": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive/-/flashpoint-archive-0.7.3.tgz", - "integrity": "sha512-HYTXjDnWi+GuokZ5HVbzauoxc/6fc2+bPxc4g5yVZxzk3U1ebQyflI9fQoYjstncLqdj6zJYVRusJIjOIKVo8A==", + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive/-/flashpoint-archive-0.7.4.tgz", + "integrity": "sha512-XbfSdQECaWPIJQrk5XB3ydA7ddAFvClhqWt7Vx6SAWNI68ckcASX/RCjtZodNdPj6ueU+SVGj03Jgu3M6oeFQg==", "engines": { "node": ">= 10" }, "optionalDependencies": { - "@fparchive/flashpoint-archive-darwin-arm64": "0.7.3", - "@fparchive/flashpoint-archive-darwin-x64": "0.7.3", - "@fparchive/flashpoint-archive-linux-x64-gnu": "0.7.3", - "@fparchive/flashpoint-archive-win32-ia32-msvc": "0.7.3", - "@fparchive/flashpoint-archive-win32-x64-msvc": "0.7.3" + "@fparchive/flashpoint-archive-darwin-arm64": "0.7.4", + "@fparchive/flashpoint-archive-darwin-x64": "0.7.4", + "@fparchive/flashpoint-archive-linux-x64-gnu": "0.7.4", + "@fparchive/flashpoint-archive-win32-ia32-msvc": "0.7.4", + "@fparchive/flashpoint-archive-win32-x64-msvc": "0.7.4" } }, "node_modules/@fparchive/flashpoint-archive-darwin-arm64": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive-darwin-arm64/-/flashpoint-archive-darwin-arm64-0.7.3.tgz", - "integrity": "sha512-G0Favyei1Z7mxw7WKUbnK0Z8QHqLmjw9YwctjIfUZGr8OIAvKMeQVucUgf/R8KW0ZEcT/6d+qjkXE/TJF1OpRw==", + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive-darwin-arm64/-/flashpoint-archive-darwin-arm64-0.7.4.tgz", + "integrity": "sha512-FVbQEoJnttPEYhaeaK8i7McOnEWX6hMRX//c6BFHqzeuybP+EHkqQP9dLE5dvGIuPvn/M/prbpBvTMnLP7laqQ==", "cpu": [ "arm64" ], @@ -1021,9 +1021,9 @@ } }, "node_modules/@fparchive/flashpoint-archive-darwin-x64": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive-darwin-x64/-/flashpoint-archive-darwin-x64-0.7.3.tgz", - "integrity": "sha512-mzoguno8u/N3UPjsrD91jv6UmJl/jG2xlrc90WTVdIy73RX6pg3vQnFWro54OWsFeDVr9kXe9VhiSKJSgR7Rog==", + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive-darwin-x64/-/flashpoint-archive-darwin-x64-0.7.4.tgz", + "integrity": "sha512-3h8fdfW+mx3rp2dCg1gtDbmSybqOgGP85F2g01HHLkKDXFwqP0iGt3VNgsQjDiPapQBkxQFvENhM50jJzGIrjg==", "cpu": [ "x64" ], @@ -1036,9 +1036,9 @@ } }, "node_modules/@fparchive/flashpoint-archive-linux-x64-gnu": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive-linux-x64-gnu/-/flashpoint-archive-linux-x64-gnu-0.7.3.tgz", - "integrity": "sha512-0IxYcdjanlzaDZMN8pReHFbS4Yrob2RAqjtFtDBNEzHaP8Yfh48K/b1kQoh6Q6Axnz7+hpa2/hzWncfkOn5pzA==", + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive-linux-x64-gnu/-/flashpoint-archive-linux-x64-gnu-0.7.4.tgz", + "integrity": "sha512-TEMb2TzqdOtPbg/ulwOZ7eo8dD1wAuK7FdC4N5NAwVZQ4HKtFVsyZ33IbGUb85+bQG/V1QQoTyQf/Hy15+erWA==", "cpu": [ "x64" ], @@ -1051,9 +1051,9 @@ } }, "node_modules/@fparchive/flashpoint-archive-win32-ia32-msvc": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive-win32-ia32-msvc/-/flashpoint-archive-win32-ia32-msvc-0.7.3.tgz", - "integrity": "sha512-/anCLhPy+3GPf+8FTDY5ZLh3NnebWGsQOcySGvatapeooI0PmsVHWXb/OEvb3pVO42OXjtmSfDdv513la4AnjA==", + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive-win32-ia32-msvc/-/flashpoint-archive-win32-ia32-msvc-0.7.4.tgz", + "integrity": "sha512-MIYICKlXZ6ymUB/LLzJuHiySphz9Vh0+sTFAGIFhjRkp8UAlhfWLh1B7coAvCu/3n9bfoAyyKBZJCAqoV8m7jw==", "cpu": [ "ia32" ], @@ -1066,9 +1066,9 @@ } }, "node_modules/@fparchive/flashpoint-archive-win32-x64-msvc": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive-win32-x64-msvc/-/flashpoint-archive-win32-x64-msvc-0.7.3.tgz", - "integrity": "sha512-WsxzC/cGpkmlfwBuPQV+O49DR6hS2sy0A5Aep7gJewvvWHH/vy1WXVy0fiRmQZNoKPoz4ptt09zxfpQZyIuntg==", + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@fparchive/flashpoint-archive-win32-x64-msvc/-/flashpoint-archive-win32-x64-msvc-0.7.4.tgz", + "integrity": "sha512-pEnU3p/+MO4FQkee1qErqYl4HeLrJuDIAzBhZ7iNpnHQy0+Vpkaa44VObCZBqp0NhMnZa9RwnCCb5A1jdiAl2w==", "cpu": [ "x64" ], diff --git a/package.json b/package.json index 159ed056f..d7656ba28 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/back/responses.ts b/src/back/responses.ts index b10e9b662..563ded8cf 100644 --- a/src/back/responses.ts +++ b/src/back/responses.ts @@ -2252,6 +2252,13 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise { + 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); diff --git a/src/renderer/app.tsx b/src/renderer/app.tsx index 9177718c1..0b2096077 100644 --- a/src/renderer/app.tsx +++ b/src/renderer/app.tsx @@ -1335,7 +1335,14 @@ export class App extends React.Component { }); }); } - }, { 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) { diff --git a/src/shared/back/types.ts b/src/shared/back/types.ts index 298a29214..529302eb6 100644 --- a/src/shared/back/types.ts +++ b/src/shared/back/types.ts @@ -157,6 +157,7 @@ export enum BackIn { OPTIMIZE_DATABASE, PRE_UPDATE_INFO, CLEAR_PLAYTIME_TRACKING, + CLEAR_PLAYTIME_TRACKING_BY_ID, KEEP_ALIVE, // Dialogs @@ -380,6 +381,7 @@ export type BackInTemplate = SocketTemplate void; [BackIn.PRE_UPDATE_INFO]: (source: GameMetadataSource) => number; [BackIn.CLEAR_PLAYTIME_TRACKING]: () => Promise; + [BackIn.CLEAR_PLAYTIME_TRACKING_BY_ID]: (gameId: string) => Promise; [BackIn.KEEP_ALIVE]: () => void; // Developer