Refactor Steam sync UI logic and extract helper functions#461
Refactor Steam sync UI logic and extract helper functions#461Doezer wants to merge 3 commits intorelease/1.3.0from
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request aims to enhance the Steam wishlist synchronization feature by refactoring its backend logic for better modularity and improving the frontend user experience with React Query mutations, loading states, and refined error handling. The changes make the sync process more robust and provide clearer feedback to the user. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request successfully refactors the Steam wishlist sync feature, enhancing both the frontend user experience and the backend code structure. On the frontend, the integration of React Query mutations provides improved loading states and error handling, leading to a smoother user interaction. On the backend, the extraction of linkExistingGamesToSteam and addNewSteamWishlistGames helper functions significantly improves modularity, readability, and maintainability of the synchronization logic. The overall changes are well-implemented and align with the stated goals of the pull request.
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the Steam wishlist sync flow by extracting backend helper functions and updating the frontend “Sync Steam” UI to use a React Query mutation for improved loading/error feedback.
Changes:
- Split
syncUserSteamWishlistbackend logic intolinkExistingGamesToSteamandaddNewSteamWishlistGames. - Update the header “Sync Steam” button to use
useMutation+apiRequest, with a spinner while syncing. - Add a backend unit test covering the “no IGDB match” case.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| server/cron.ts | Extracts Steam wishlist sync steps into helpers and refactors the main sync function to use them. |
| server/tests/steam_wishlist.test.ts | Adds test coverage for skipping Steam app IDs that have no IGDB mapping. |
| client/src/components/Header.tsx | Replaces manual fetch with a React Query mutation and adds a loading indicator during sync. |
|
|
||
| for (const steamAppId of pendingSteamAppIds) { | ||
| const igdbId = steamToIgdbMap.get(steamAppId); | ||
| if (!igdbId) { |
| for (const steamAppId of pendingSteamAppIds) { | ||
| const igdbId = steamToIgdbMap.get(steamAppId); | ||
| if (!igdbId || ownedIgdbIds.has(igdbId)) continue; | ||
|
|
| if (ownedIgdbIds.has(igdbId)) { | ||
| const existing = currentGames.find((g) => g.igdbId === igdbId); | ||
| if (existing && !existing.steamAppId) { | ||
| await storage.updateGame(existing.id, { steamAppId }); | ||
| } |
| interface SteamSyncGameSet { | ||
| currentGames: Game[]; | ||
| ownedIgdbIds: Set<number | null>; | ||
| ownedSteamAppIds: Set<number | null>; | ||
| } | ||
|
|
||
| /** Link existing games that match by IGDB ID but are missing their Steam App ID. */ | ||
| async function linkExistingGamesToSteam( | ||
| pendingSteamAppIds: number[], | ||
| steamToIgdbMap: Map<number, number>, | ||
| { currentGames, ownedIgdbIds }: SteamSyncGameSet | ||
| ): Promise<Set<number>> { | ||
| const newIgdbIdsToFetch = new Set<number>(); | ||
|
|



This pull request refactors and improves the Steam wishlist sync feature, making the code more modular and robust while enhancing the user experience in the UI. The main changes include splitting the sync logic into smaller functions, updating the UI to use React Query mutations for better feedback, and improving error handling and notifications.
Steam wishlist sync backend refactor:
syncUserSteamWishlistlogic into two helper functions:linkExistingGamesToSteamfor linking existing games andaddNewSteamWishlistGamesfor adding new games, improving code readability and maintainability.Frontend improvements for Steam sync:
Loader2icon to visually indicate when the sync is in progress.