Skip to content

Refactor Steam sync UI logic and extract helper functions#461

Open
Doezer wants to merge 3 commits intorelease/1.3.0from
1.3.0/refacto-steam-sync-fetch
Open

Refactor Steam sync UI logic and extract helper functions#461
Doezer wants to merge 3 commits intorelease/1.3.0from
1.3.0/refacto-steam-sync-fetch

Conversation

@Doezer
Copy link
Owner

@Doezer Doezer commented Mar 15, 2026

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:

  • Split the syncUserSteamWishlist logic into two helper functions: linkExistingGamesToSteam for linking existing games and addNewSteamWishlistGames for adding new games, improving code readability and maintainability.
  • Updated the sync process to use these helper functions, ensuring accurate linking and addition of games, and improved notification messages for users.

Frontend improvements for Steam sync:

  • Replaced the manual fetch logic in the Steam sync button with a React Query mutation, providing loading states and improved error handling for a smoother user experience.
  • Added the Loader2 icon to visually indicate when the sync is in progress.
  • Updated imports to include new dependencies required for the mutation and loading indicator.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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

  • Backend Refactor: The core syncUserSteamWishlist function was broken down into two specialized helper functions: linkExistingGamesToSteam for updating existing game entries with their Steam App IDs, and addNewSteamWishlistGames for adding entirely new games from the wishlist, significantly improving code modularity and readability.
  • Frontend UI Enhancement: The Steam sync button in the UI now utilizes React Query's useMutation hook, replacing the previous manual fetch logic. This change introduces proper loading states, more robust error handling, and visual feedback with a Loader2 icon during the synchronization process, enhancing the user experience.
Changelog
  • client/src/components/Header.tsx
    • Imported Loader2 icon and useMutation hook for new functionality.
    • Replaced the manual fetch call for Steam sync with a useMutation hook from React Query.
    • Implemented onSuccess and onError callbacks for the mutation to display toast notifications.
    • Updated the Steam sync button to be disabled during pending mutations and display a Loader2 spinner.
  • server/cron.ts
    • Introduced a SteamSyncGameSet interface to standardize game data passed between sync functions.
    • Extracted linkExistingGamesToSteam function to handle updating existing games with Steam App IDs.
    • Extracted addNewSteamWishlistGames function to manage fetching details and adding new games from the wishlist.
    • Refactored the syncUserSteamWishlist function to utilize the newly created helper functions, streamlining its logic.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sonarqubecloud
Copy link

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 syncUserSteamWishlist backend logic into linkExistingGamesToSteam and addNewSteamWishlistGames.
  • 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) {
Comment on lines +901 to +904
for (const steamAppId of pendingSteamAppIds) {
const igdbId = steamToIgdbMap.get(steamAppId);
if (!igdbId || ownedIgdbIds.has(igdbId)) continue;

Comment on lines +875 to +879
if (ownedIgdbIds.has(igdbId)) {
const existing = currentGames.find((g) => g.igdbId === igdbId);
if (existing && !existing.steamAppId) {
await storage.updateGame(existing.id, { steamAppId });
}
Comment on lines +854 to +867
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>();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants