diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2023-07-06 13:09:51 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2023-07-07 09:14:51 +0200 |
| commit | d77758c583497598d728eb1dbb17fd4637334bfa (patch) | |
| tree | ed9bde044421dbda2e4e3e947f20af16e93b7894 | |
| parent | b0441f5620b2463f9fc750da0232709dce0ea1da (diff) | |
| download | mullvadvpn-d77758c583497598d728eb1dbb17fd4637334bfa.tar.xz mullvadvpn-d77758c583497598d728eb1dbb17fd4637334bfa.zip | |
Update account expiry fetch logic
| -rw-r--r-- | gui/src/main/user-interface.ts | 6 | ||||
| -rw-r--r-- | gui/src/renderer/components/MainView.tsx | 6 | ||||
| -rw-r--r-- | gui/src/renderer/components/Settings.tsx | 9 |
3 files changed, 8 insertions, 13 deletions
diff --git a/gui/src/main/user-interface.ts b/gui/src/main/user-interface.ts index 4376043f87..833edac26d 100644 --- a/gui/src/main/user-interface.ts +++ b/gui/src/main/user-interface.ts @@ -4,7 +4,6 @@ import path from 'path'; import { sprintf } from 'sprintf-js'; import { promisify } from 'util'; -import { closeToExpiry, hasExpired } from '../shared/account-expiry'; import { connectEnabled, disconnectEnabled, reconnectEnabled } from '../shared/connect-helper'; import { IAccountData, ILocation, TunnelState } from '../shared/daemon-rpc-types'; import { messages, relayLocations } from '../shared/gettext'; @@ -325,10 +324,7 @@ export default class UserInterface implements WindowControllerDelegate { // cancel notifications when window appears this.delegate.dismissActiveNotifications(); - const accountData = this.delegate.getAccountData(); - if (!accountData || closeToExpiry(accountData.expiry, 4) || hasExpired(accountData.expiry)) { - this.delegate.updateAccountData(); - } + this.delegate.updateAccountData(); }); this.windowController.window?.on('blur', () => { diff --git a/gui/src/renderer/components/MainView.tsx b/gui/src/renderer/components/MainView.tsx index 5a252c4d8b..9269013732 100644 --- a/gui/src/renderer/components/MainView.tsx +++ b/gui/src/renderer/components/MainView.tsx @@ -3,6 +3,7 @@ import { useEffect, useState } from 'react'; import { hasExpired } from '../../shared/account-expiry'; import { AuthFailedError, ErrorStateCause } from '../../shared/daemon-rpc-types'; import Connect from '../components/Connect'; +import { useAppContext } from '../context'; import { useHistory } from '../lib/history'; import { RoutePath } from '../lib/routes'; import { useSelector } from '../redux/store'; @@ -11,6 +12,7 @@ import ExpiredAccountErrorView from './ExpiredAccountErrorView'; type ExpiryData = { show: false } | { show: true; expiry: string | undefined }; export default function MainView() { + const { updateAccountData } = useAppContext(); const history = useHistory(); const accountExpiry = useSelector((state) => state.account.expiry); const accountHasExpired = accountExpiry !== undefined && hasExpired(accountExpiry); @@ -24,6 +26,10 @@ export default function MainView() { ); useEffect(() => { + updateAccountData(); + }, []); + + useEffect(() => { if ( (!showAccountExpired.show || showAccountExpired.expiry !== accountExpiry) && (accountHasExpired || diff --git a/gui/src/renderer/components/Settings.tsx b/gui/src/renderer/components/Settings.tsx index ce84ae1661..01becd27b6 100644 --- a/gui/src/renderer/components/Settings.tsx +++ b/gui/src/renderer/components/Settings.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect } from 'react'; +import { useCallback } from 'react'; import { colors, links } from '../../config.json'; import { messages } from '../../shared/gettext'; @@ -22,13 +22,6 @@ import { export default function Support() { const history = useHistory(); - const { updateAccountData } = useAppContext(); - - useEffect(() => { - if (history.action === 'PUSH') { - updateAccountData(); - } - }, []); const loginState = useSelector((state) => state.account.status); const connectedToDaemon = useSelector((state) => state.userInterface.connectedToDaemon); |
