Skip to content

Commit

Permalink
FIXUP: Fix location cache in Electron app
Browse files Browse the repository at this point in the history
  • Loading branch information
raksooo committed Dec 8, 2023
1 parent 95bd4b8 commit d7baa41
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions gui/src/main/tunnel-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export default class TunnelStateHandler {
this.tunnelStateFallback = this.tunnelState;

this.setTunnelState(
state === 'disconnecting' ? { state, details: 'nothing' as const } : { state },
state === 'disconnecting'
? { state, details: 'nothing' as const, location: this.lastKnownDisconnectedLocation }
: { state },
);

this.tunnelStateFallbackScheduler.schedule(() => {
Expand Down Expand Up @@ -69,18 +71,18 @@ export default class TunnelStateHandler {
this.expectNextTunnelState('connecting');
this.tunnelStateFallback = newState;
} else {
this.setTunnelState(newState);
}
if (newState.state === 'disconnected' && newState.location !== undefined) {
this.lastKnownDisconnectedLocation = newState.location;
}

if (newState.state === 'disconnected' && newState.location !== undefined) {
this.lastKnownDisconnectedLocation = newState.location;
}
if (
newState.state === 'disconnecting' ||
(newState.state === 'disconnected' && newState.location === undefined)
) {
newState.location = this.lastKnownDisconnectedLocation;
}

if (
newState.state === 'disconnecting' ||
(newState.state === 'disconnected' && newState.location === undefined)
) {
newState.location = this.lastKnownDisconnectedLocation;
this.setTunnelState(newState);
}
}

Expand Down

0 comments on commit d7baa41

Please sign in to comment.