Skip to content

Conversation

@CommandMC
Copy link
Collaborator

This implements the changes I've mentioned here: #5014 (review)

The Frontend now uses a Zustand store to house playtime information. If the playtime changes, the Backend sends updates to it & the Frontend just re-renders automatically

Playtime tracking in the Backend is done automatically with a new playSessionEnded event, emitted at the end of launchCallback. A new PlaytimeManager class listens to this event and updates playtime accordingly. The GOG library manager also listens to this event to sync the playtime with GOG

In the process, I've made some housekeeping changes:

  • Playtime store keys are now of type ${string}_${Runner}, to avoid game ID collisions
    • This is mentioned in the code, but just to have it here as well: This doesn't use the migration system, since the system runs too early
  • The strings shown to the user now get the playtime number / first/last play date as parameters, so other locales may change their position
  • First/last play dates are generated using a locale-aware Intl.DateTimeFormat (it used the system locale before, which may not be the locale the user configured)
  • Total playtime is formatted using a Intl.DurationFormat to present the duration in a more friendly format, and now includes seconds
    • I've had to write a typedef for DurationFormat for this, since it's not in TypeScript yet (for some reason)

TODO:

Notes:

  • The playtime updates could've used the gameStatusUpdate event instead, but it seems we currently emit the done status multiple times. Cleaning that up may cause side-effects, so I left it alone for now

Use the following Checklist if you have changed something on the Backend or Frontend:

  • Tested the feature and it's working on a current and clean install.
  • Tested the main App features and they are still working on a current and clean install. (Login, Install, Play, Uninstall, Move games, etc.)
  • Created / Updated Tests (If necessary)
  • Created / Updated documentation (If necessary)

@CommandMC CommandMC self-assigned this Nov 15, 2025
@CommandMC CommandMC added the pr:wip WIP, don't merge. label Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:wip WIP, don't merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants