Skip to content

fix(connection): close the no internet dialog once the connection is back - #266

Merged
tonyco97 merged 1 commit into
mainfrom
fix/connection-dialog-refresh
Nov 17, 2026
Merged

tonyco97 merged 1 commit into
mainfrom
fix/connection-dialog-refresh

Conversation

@tonyco97

@tonyco97 tonyco97 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Reference:

Once the "No internet connection" dialog is shown, it never closes: "Refresh" does nothing and the dialog does not close by itself when the connection is back. The only way out is to restart NethLink.

Changes

  • mainStore.set() compares only the value of the changed key.
    • It used to compare the values of all the store keys with lodash.difference, so a value was discarded whenever another key already held it. Since cameraPermission: true is in the store (1.6.0-testing.10), set('connection', true) is always discarded and "Refresh" never reaches the windows. In the same way set('connection', false) was discarded while isCallsEnabled is false.
    • All the other callers are unaffected: they pass force (account, auth, theme from the account controller, cameraPermission), or theme values (dark/light) that no other key holds.
  • PhoneIsland internet event handlers read the current account and connection through refs.
    • The listeners are attached once with the handlers of the first render, so phone-island-internet-connected compared against the first connection value (true) and never restored it.

Validation

  • npm run typecheck: OK.

  • npm run build: OK.

  • npx eslint on the changed files: 0 errors, same warnings as main.

  • mainStore.ts of main and of this branch, bundled and run with a mocked electron: same results for every case (theme, account with and without force, cameraPermission, unchanged values) except connection false → true and true → false, now applied and broadcast.

  • End-to-end on the production build (file:// renderer, electron . on out/), same logged in user, driven through the Chrome DevTools Protocol. The dialog is opened by dispatching phone-island-internet-disconnected in the PhoneIsland window:

    Test main this branch
    Refresh with the network up, periodic phone-island-internet-connected events suppressed (dialog still open after 7 s without clicking) dialog still open 8 s after the click closed 256 ms after the click
    No click, wait for the periodic PhoneIsland connectivity check still open after more than 40 s closed by itself after ~3 s
    Refresh with the NethLink window offline (network emulation) - dialog stays open
    Refresh after the network is back - closed 202 ms after the click

    The Refresh check can't be tested with npm run dev: from http://localhost:5173 the connectivity endpoints are blocked by CORS, so the check always reports offline. In the packaged app the renderer is loaded from file:// and the check works.

@tonyco97 tonyco97 self-assigned this Nov 17, 2026
@github-actions

Copy link
Copy Markdown

Automatic builds from https://github.com/NethServer/nethlink/actions/runs/44073687830.
Commit: d48cd06

Name Platform Link
win-app.exe Windows (x64) Link
macos-app-x64.dmg MacOS (x64) Link
macos-app-arm64.dmg MacOS (arm64) Link
linux-app.AppImage Linux (x64) Link

@edospadoni edospadoni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

  • mainStore.set(): confirmed. account/auth in o are the same references as in this.store, so they never produce a diff, and any primitive already held by another key (cameraPermission: true, isCallsEnabled: false) was silently dropped. As a side effect this also stops the periodic checkConnection() in main from re-emitting UPDATE_CONNECTION_STATE on every cycle, since store.store.connection is now kept in sync. The other callers pass force or 'dark'/'light' themes, so their behaviour does not change, and there is no feedback loop because SHARED_STATE_UPDATED only updates the local state.
  • PhoneIsland internet handlers: the refs are the right fix for the stale closures of listeners registered once.

Non-blocking notes:

  • updateStore() still uses the same difference check. In practice it doesn't trigger, because state coming from the renderer through IPC always carries new object references, but it's worth aligning in a follow-up.
  • The ?. in (this.store as any)?.[selector] isn't needed, since store is always initialized.

@tonyco97
tonyco97 merged commit 3533fa0 into main Nov 17, 2026
4 checks passed
@tonyco97
tonyco97 deleted the fix/connection-dialog-refresh branch November 17, 2026 13:09
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