diff options
| author | Oskar <oskar@mullvad.net> | 2025-10-09 13:21:20 +0200 |
|---|---|---|
| committer | Oskar <oskar@mullvad.net> | 2025-10-09 13:21:20 +0200 |
| commit | 2fd2b36e092a74a5686b4f725ccaf14669685441 (patch) | |
| tree | 7f90c2ce50de5ed02d17468d2796ed94fc78b1d4 | |
| parent | 6992fc2142a654eb2b5ff18d903ec35c78cfc649 (diff) | |
| parent | 668fa98c9516c6c5bca9088ee082b84d0881d126 (diff) | |
| download | mullvadvpn-2fd2b36e092a74a5686b4f725ccaf14669685441.tar.xz mullvadvpn-2fd2b36e092a74a5686b4f725ccaf14669685441.zip | |
Merge branch 'maintime-added-is-incorrectly-shown-on-log-out-from-expired-des-2582'
5 files changed, 17 insertions, 23 deletions
diff --git a/desktop/packages/mullvad-vpn/src/main/account.ts b/desktop/packages/mullvad-vpn/src/main/account.ts index 7ee415c0b4..dc6e3f8f97 100644 --- a/desktop/packages/mullvad-vpn/src/main/account.ts +++ b/desktop/packages/mullvad-vpn/src/main/account.ts @@ -125,6 +125,14 @@ export default class Account { this.deviceStateValue = deviceEvent.deviceState; + void this.updateAccountHistory(); + this.delegate.onDeviceEvent(); + + // When logging out the renderer process needs to receive the device update before the account + // data update. This means that the ipc-call `account.notifyDevice` needs to be called before + // invalidating the accountDateCache since that triggers the ipc-call `account.notify`. + IpcMainEventChannel.account.notifyDevice?.(deviceEvent); + switch (deviceEvent.deviceState.type) { case 'logged in': this.accountDataCache.fetch(deviceEvent.deviceState.accountAndDevice.accountNumber); @@ -134,11 +142,6 @@ export default class Account { this.accountDataCache.invalidate(); break; } - - void this.updateAccountHistory(); - this.delegate.onDeviceEvent(); - - IpcMainEventChannel.account.notifyDevice?.(deviceEvent); } public setAccountHistory(accountHistory?: AccountNumber) { diff --git a/desktop/packages/mullvad-vpn/src/renderer/components/StateTriggeredNavigation.tsx b/desktop/packages/mullvad-vpn/src/renderer/components/StateTriggeredNavigation.tsx index 3a275e2f61..3ecc36c60b 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/components/StateTriggeredNavigation.tsx +++ b/desktop/packages/mullvad-vpn/src/renderer/components/StateTriggeredNavigation.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo } from 'react'; +import { useEffect, useMemo, useRef } from 'react'; import { RoutePath } from '../../shared/routes'; import { useScheduler } from '../../shared/scheduler'; @@ -15,6 +15,7 @@ export default function StateTriggeredNavigation() { const delayScheduler = useScheduler(); + const prevPath = useRef<RoutePath>(getNavigationBase(connectedToDaemon, loginState)); const nextPath = useMemo( () => getNavigationBase(connectedToDaemon, loginState), [connectedToDaemon, loginState], @@ -42,7 +43,10 @@ export default function StateTriggeredNavigation() { }); useEffect(() => { - updatePath(nextPath); + if (nextPath !== prevPath.current) { + prevPath.current = nextPath; + updatePath(nextPath); + } // eslint-disable-next-line react-compiler/react-compiler // eslint-disable-next-line react-hooks/exhaustive-deps }, [nextPath]); diff --git a/desktop/packages/mullvad-vpn/src/renderer/lib/history.tsx b/desktop/packages/mullvad-vpn/src/renderer/lib/history.tsx index f661a5f191..a0d77ed6c0 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/lib/history.tsx +++ b/desktop/packages/mullvad-vpn/src/renderer/lib/history.tsx @@ -89,19 +89,6 @@ export default class History { this.notify(nextState?.transition ?? TransitionType.none); }; - public replaceRoot = ( - replacementLocation: LocationDescriptor, - replacementState?: Partial<LocationState>, - ) => { - const location = this.createLocation(replacementLocation, replacementState); - this.lastAction = 'REPLACE'; - this.entries.splice(0, 1, location); - - if (this.index === 0) { - this.notify(replacementState?.transition ?? TransitionType.none); - } - }; - public listen(callback: LocationListener) { this.listeners.push(callback); return () => (this.listeners = this.listeners.filter((listener) => listener !== callback)); diff --git a/desktop/packages/mullvad-vpn/src/renderer/redux/account/actions.ts b/desktop/packages/mullvad-vpn/src/renderer/redux/account/actions.ts index 98a689cd76..2dcd7f030d 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/redux/account/actions.ts +++ b/desktop/packages/mullvad-vpn/src/renderer/redux/account/actions.ts @@ -70,7 +70,7 @@ interface IUpdateAccountHistoryAction { interface IUpdateAccountExpiryAction { type: 'UPDATE_ACCOUNT_EXPIRY'; expiry?: string; - expired: boolean; + expired?: boolean; } interface IUpdateDevicesAction { @@ -194,7 +194,7 @@ function updateAccountExpiry(expiry?: string): IUpdateAccountExpiryAction { return { type: 'UPDATE_ACCOUNT_EXPIRY', expiry, - expired: expiry !== undefined && hasExpired(expiry), + expired: expiry === undefined ? undefined : hasExpired(expiry), }; } diff --git a/desktop/packages/mullvad-vpn/src/renderer/redux/account/reducers.ts b/desktop/packages/mullvad-vpn/src/renderer/redux/account/reducers.ts index 46b6117ae5..13e9fd5a2b 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/redux/account/reducers.ts +++ b/desktop/packages/mullvad-vpn/src/renderer/redux/account/reducers.ts @@ -132,7 +132,7 @@ export default function ( status.expiredState = 'expired'; } else if ( status.expiredState === 'expired' && - !action.expired && + action.expired === false && // If the system clock changes from something that makes the expiry out of time, backwards // to something that is before the expiry, then the time added view shouldn't be displayed // since the expiry hasn't changed. |
