Skip to content

fix: clear GOG presence when disabling the setting - #5472

Merged
arielj merged 3 commits into
Heroic-Games-Launcher:mainfrom
reverb256:fix/5443-gog-presence-clear
Apr 15, 2026
Merged

arielj merged 3 commits into
Heroic-Games-Launcher:mainfrom
reverb256:fix/5443-gog-presence-clear

Conversation

@reverb256

Copy link
Copy Markdown
Contributor

Problem

When Disable GOG Presence updates is enabled and the app is closed, the user still shows as Online on gog.com. The presence is never cleared.

Root Cause

deletePresence() in src/backend/storeManagers/gog/presence.ts has a disableGOGPresence guard that causes it to return early when the setting is enabled — exactly when presence needs to be deleted.

Fix

Removed the disableGOGPresence check from deletePresence(). The disablePlaytimeSync, isLoggedIn(), and isOnline() guards remain as valid reasons to skip the API call.

Closes #5443

@flavioislima

flavioislima commented Apr 10, 2026 •

Copy link
Copy Markdown
Member

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@reverb256

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@arielj

arielj commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator

While this fixes the basic problem, I think we should have a better solution that calls deletePresence as soon as we turn that off (now we still have the issue that when the presence is set, it's going to still show the presence even after disabling it until you close heroic).

A better solution would be to:

  • when heroic starts, if presence is turned on, call the setPresence
  • when a user turns off the presence, call deletePresence
  • when a user turns on the presence, call setPresence
  • when heroic closes, if presence is turned on, call deletePresence

it would require listening to the config changed events and a bit of logic changes, but I think it will be a better fix, since the change in this PR solves only one of the different things listed in that issue

@reverb256
reverb256 force-pushed the fix/5443-gog-presence-clear branch from 83276fa to acd1994 Compare April 11, 2026 02:05
@reverb256

Copy link
Copy Markdown
Contributor Author

@arielj Thanks for the thorough review! You're right — my initial fix only addressed the symptom.

I've updated the PR to handle all 4 scenarios:

  1. Startup → setPresence already called in main.ts on boot ✅
  2. Disable → Now calls deletePresence immediately via settingChanged listener ✅
  3. Enable → Now calls setPresence immediately via settingChanged listener ✅
  4. Shutdown → deletePresence already called in utils.ts on exit ✅

The approach follows the existing pattern used by plausible.ts and logger/index.ts — listening to backendEvents.settingChanged. I also fixed a latent bug where clearInterval(interval) didn't reset the reference, so re-enabling wouldn't recreate the refresh timer.

Please take another look when you get a chance.

import { app } from 'electron'
import { GOGUser } from './user'
import { isOnline } from 'backend/online_monitor'
import { GlobalConfig } from 'backend/config'

@arielj arielj Apr 11, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't rearrange these things, it adds noise to the PR to not know at first glance what's an actual change and what's just reordering. Reordering is not needed.

I imagine this is made by AI, please don't just push any change made by AI, cleanup the changes and only send the minimal changes needed. Don't throw the burden of cleaning the AI generated code to the reviewers.

GlobalConfig.get().getSettings()
if (
disablePlaytimeSync ||
disableGOGPresence ||

@arielj arielj Apr 11, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

removing this check would result in heroic always trying to delete the gog presence, even when not needed at all every time heroic is closed, we shouldn't do that (it executes the gogdl binary to check for auth information and makes a request to gog even when not needed)

instead, maybe add a new optional parameter to the deletePresence function to be able force the call even if the presence is turned off and pass true when the deletePresence function is called when the setting changes instead of removing this check

@reverb256

Copy link
Copy Markdown
Contributor Author

@arielj Good points, both addressed in the latest push:

  1. Import reordering noise — removed, imports kept in original order with only the new backendEvents import added in place.

  2. Guard removal in deletePresence — reverted. Added a force parameter instead, so the normal code path (shutdown, etc.) still checks disableGOGPresence and avoids unnecessary GOG API calls. Only the settingChanged handler passes force=true to bypass the guard when the user explicitly toggles the setting off.

Also fixed a latent bug where clearInterval(interval) didn't reset the reference, so re-enabling presence wouldn't recreate the refresh timer.

@reverb256

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @arielj — good catches, both.

Condition reordering: Fixed. The guard now stays at its original position, just wrapped inline with (!force && disableGOGPresence) so the diff only shows the actual logic change.

Unrelated interval = undefined fix: Removed from this PR. I'll submit that separately if needed.

The force parameter approach you suggested is exactly right — existing callers keep their guard, only the settingChanged listener passes force=true to bypass it.

Listen to backendEvents.settingChanged to clear/set GOG presence
when the user toggles disableGOGPresence in settings.

- Add force parameter to deletePresence to bypass disableGOGPresence
  guard when called from the setting toggle (avoids unnecessary GOG
  API calls on shutdown when presence is already off)
- Preserves existing guards on normal (non-forced) deletePresence calls

Closes Heroic-Games-Launcher#5443
@reverb256
reverb256 force-pushed the fix/5443-gog-presence-clear branch from d03ba7d to a117441 Compare April 13, 2026 01:01
}
}


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

there's an extra new line here, remove that please so it's not changed for other people in the future if they touch this file

@arielj

arielj commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

@reverb256, the lint job keeps complaining about style issues https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/actions/runs/24394668774/job/71249342911

do you have the pre-commit hooks configured to run the prettier checks before pushing code to github? do not skip that

@reverb256

Copy link
Copy Markdown
Contributor Author

Thanks for the review @arielj! I've cleaned up the PR:

  1. Import reordering — Reverted, imports are back in original order. The earlier commits had formatter noise which I've removed.
  2. Line 72 check — The disableGOGPresence check is still there on line 80: (!force && disableGOGPresence). The only change in deletePresence is that it now also gets called with force=true from the settings toggle listener (line 100), so the existing check correctly skips deletion when the user has presence disabled AND it's not a forced toggle.
  3. Extra blank line — Removed.

The full diff should now be minimal — just the void additions on the floating promises and the settings toggle listener.

@arielj

arielj commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

thanks, it works fine

next time PLEASE answer like a person and not just with AI generated output, I don't like talking to an AI

@arielj
arielj merged commit 5fb331e into Heroic-Games-Launcher:main Apr 15, 2026
10 checks passed
@Heroic-Games-Launcher Heroic-Games-Launcher locked and limited conversation to collaborators Apr 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disabling GOG presence updates does not unset the current logged in state

3 participants