summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorEmīls <emils@mullvad.net>2020-06-11 23:23:05 +0100
committerEmīls <emils@mullvad.net>2020-06-25 15:21:31 +0100
commit0815cb48730fdd6c8e6435dac410aa8acd36bab4 (patch)
treecf47e4dc81c1cc2743520be70e085a29f4c4b746 /gui/src
parentb7bbbb05fe4a44fdb87cd9d8842fa96956f12c3f (diff)
downloadmullvadvpn-0815cb48730fdd6c8e6435dac410aa8acd36bab4.tar.xz
mullvadvpn-0815cb48730fdd6c8e6435dac410aa8acd36bab4.zip
Update GUI to not show update info if the app is too new
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/daemon-rpc.ts4
-rw-r--r--gui/src/main/index.ts48
-rw-r--r--gui/src/renderer/app.tsx7
-rw-r--r--gui/src/renderer/containers/SettingsPage.tsx4
-rw-r--r--gui/src/renderer/containers/SupportPage.tsx4
-rw-r--r--gui/src/renderer/redux/version/actions.ts8
-rw-r--r--gui/src/renderer/redux/version/reducers.ts12
-rw-r--r--gui/src/shared/daemon-rpc-types.ts4
-rw-r--r--gui/src/shared/ipc-event-channel.ts9
-rw-r--r--gui/src/shared/notifications/unsupported-version.ts46
-rw-r--r--gui/src/shared/notifications/update-available.ts7
11 files changed, 53 insertions, 100 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts
index 7740dfa26c..656efd760b 100644
--- a/gui/src/main/daemon-rpc.ts
+++ b/gui/src/main/daemon-rpc.ts
@@ -294,9 +294,7 @@ const tunnelStateSchema = oneOf(
const appVersionInfoSchema = partialObject({
supported: boolean,
- latest: string,
- latest_stable: string,
- latest_beta: string,
+ suggested_upgrade: maybe(string),
});
export class ConnectionObserver {
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 0bdc71a2ef..f23491abcb 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -77,11 +77,6 @@ export interface ICurrentAppVersionInfo {
isBeta: boolean;
}
-export interface IAppUpgradeInfo extends IAppVersionInfo {
- // Null is used since undefined properties get filtered out when sending through IPC.
- nextUpgrade: string | null;
-}
-
type AccountVerification = { status: 'verified' } | { status: 'deferred'; error: Error };
class ApplicationMain {
@@ -154,12 +149,9 @@ class ApplicationMain {
isBeta: false,
};
- private upgradeVersion: IAppUpgradeInfo = {
+ private upgradeVersion: IAppVersionInfo = {
supported: true,
- latestStable: '',
- latestBeta: '',
- latest: '',
- nextUpgrade: null,
+ suggestedUpgrade: undefined,
};
// The UI locale which is set once from onReady handler
@@ -785,45 +777,23 @@ class ApplicationMain {
}
private setLatestVersion(latestVersionInfo: IAppVersionInfo) {
- const settings = this.settings;
-
- function nextUpgrade(current: string, latest: string, latestStable: string): string | null {
- if (settings.showBetaReleases) {
- return current === latest ? null : latest;
- } else {
- return current === latestStable ? null : latestStable;
- }
- }
-
- const currentVersionInfo = this.currentVersion;
- const latestVersion = latestVersionInfo.latest;
- const latestStableVersion = latestVersionInfo.latestStable;
-
- const upgradeVersion = nextUpgrade(
- currentVersionInfo.daemon,
- latestVersion,
- latestStableVersion,
- );
-
- const upgradeInfo = {
- ...latestVersionInfo,
- nextUpgrade: upgradeVersion,
- };
-
- this.upgradeVersion = upgradeInfo;
+ this.upgradeVersion = latestVersionInfo;
// notify user to update the app if it became unsupported
const notificationProvider = new UnsupportedVersionNotificationProvider({
supported: latestVersionInfo.supported,
- consistent: currentVersionInfo.isConsistent,
- nextUpgrade: upgradeVersion,
+ consistent: this.currentVersion.isConsistent,
+ suggestedUpgrade: latestVersionInfo.suggestedUpgrade,
});
if (notificationProvider.mayDisplay()) {
this.notificationController.notify(notificationProvider.getSystemNotification());
}
if (this.windowController) {
- IpcMainEventChannel.upgradeVersion.notify(this.windowController.webContents, upgradeInfo);
+ IpcMainEventChannel.upgradeVersion.notify(
+ this.windowController.webContents,
+ latestVersionInfo,
+ );
}
}
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index f794216206..0dc076378a 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -22,7 +22,7 @@ import configureStore from './redux/store';
import userInterfaceActions from './redux/userinterface/actions';
import versionActions from './redux/version/actions';
-import { IAppUpgradeInfo, ICurrentAppVersionInfo } from '../main';
+import { ICurrentAppVersionInfo } from '../main';
import { loadTranslations, messages, relayLocations } from '../shared/gettext';
import { IGuiSettingsState, SYSTEM_PREFERRED_LOCALE_KEY } from '../shared/gui-settings-state';
import { IpcRendererEventChannel, IRelayListPair } from '../shared/ipc-event-channel';
@@ -34,6 +34,7 @@ import {
BridgeSettings,
BridgeState,
IAccountData,
+ IAppVersionInfo,
ILocation,
IRelayList,
ISettings,
@@ -166,7 +167,7 @@ export default class AppRenderer {
this.setCurrentVersion(currentVersion);
});
- IpcRendererEventChannel.upgradeVersion.listen((upgradeVersion: IAppUpgradeInfo) => {
+ IpcRendererEventChannel.upgradeVersion.listen((upgradeVersion: IAppVersionInfo) => {
this.setUpgradeVersion(upgradeVersion);
});
@@ -730,7 +731,7 @@ export default class AppRenderer {
);
}
- private setUpgradeVersion(upgradeVersion: IAppUpgradeInfo) {
+ private setUpgradeVersion(upgradeVersion: IAppVersionInfo) {
this.reduxActions.version.updateLatest(upgradeVersion);
}
diff --git a/gui/src/renderer/containers/SettingsPage.tsx b/gui/src/renderer/containers/SettingsPage.tsx
index 563b9136fb..fda21f1b7d 100644
--- a/gui/src/renderer/containers/SettingsPage.tsx
+++ b/gui/src/renderer/containers/SettingsPage.tsx
@@ -15,9 +15,7 @@ const mapStateToProps = (state: IReduxState, props: IAppContext) => ({
expiryLocale: state.userInterface.locale,
appVersion: state.version.current,
consistentVersion: state.version.consistent,
- upToDateVersion: state.settings.showBetaReleases
- ? state.version.current === state.version.latest
- : state.version.current === state.version.latestStable,
+ upToDateVersion: state.version.suggestedUpgrade ? false : true,
isOffline: state.connection.isBlocked,
});
const mapDispatchToProps = (dispatch: ReduxDispatch) => {
diff --git a/gui/src/renderer/containers/SupportPage.tsx b/gui/src/renderer/containers/SupportPage.tsx
index d8227dd4ae..7382b9d694 100644
--- a/gui/src/renderer/containers/SupportPage.tsx
+++ b/gui/src/renderer/containers/SupportPage.tsx
@@ -12,9 +12,7 @@ const mapStateToProps = (state: IReduxState) => ({
defaultMessage: state.support.message,
accountHistory: state.account.accountHistory,
isOffline: state.connection.isBlocked,
- outdatedVersion: state.settings.showBetaReleases
- ? state.version.current !== state.version.latest
- : state.version.current !== state.version.latestStable,
+ outdatedVersion: state.version.suggestedUpgrade ? true : false,
});
const mapDispatchToProps = (dispatch: ReduxDispatch) => {
diff --git a/gui/src/renderer/redux/version/actions.ts b/gui/src/renderer/redux/version/actions.ts
index e2bb4a6513..8b3f1461f4 100644
--- a/gui/src/renderer/redux/version/actions.ts
+++ b/gui/src/renderer/redux/version/actions.ts
@@ -1,12 +1,8 @@
import { IAppVersionInfo } from '../../../shared/daemon-rpc-types';
-interface IUpdateLatestActionPayload extends IAppVersionInfo {
- nextUpgrade: string | null;
-}
-
export interface IUpdateLatestAction {
type: 'UPDATE_LATEST';
- latestInfo: IUpdateLatestActionPayload;
+ latestInfo: IAppVersionInfo;
}
export interface IUpdateVersionAction {
@@ -18,7 +14,7 @@ export interface IUpdateVersionAction {
export type VersionAction = IUpdateLatestAction | IUpdateVersionAction;
-function updateLatest(latestInfo: IUpdateLatestActionPayload): IUpdateLatestAction {
+function updateLatest(latestInfo: IAppVersionInfo): IUpdateLatestAction {
return {
type: 'UPDATE_LATEST',
latestInfo,
diff --git a/gui/src/renderer/redux/version/reducers.ts b/gui/src/renderer/redux/version/reducers.ts
index fcc23c7f3d..96e8ab0aa3 100644
--- a/gui/src/renderer/redux/version/reducers.ts
+++ b/gui/src/renderer/redux/version/reducers.ts
@@ -4,9 +4,7 @@ export interface IVersionReduxState {
current: string;
supported: boolean;
isBeta: boolean;
- latest?: string;
- latestStable?: string;
- nextUpgrade: string | null;
+ suggestedUpgrade?: string;
consistent: boolean;
}
@@ -14,9 +12,7 @@ const initialState: IVersionReduxState = {
current: '',
supported: true,
isBeta: false,
- latest: undefined,
- latestStable: undefined,
- nextUpgrade: null,
+ suggestedUpgrade: undefined,
consistent: true,
};
@@ -28,10 +24,8 @@ export default function (
case 'UPDATE_LATEST':
return {
...state,
- nextUpgrade: action.latestInfo.nextUpgrade,
supported: action.latestInfo.supported,
- latest: action.latestInfo.latest,
- latestStable: action.latestInfo.latestStable,
+ suggestedUpgrade: action.latestInfo.suggestedUpgrade,
};
case 'UPDATE_VERSION':
diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts
index 7d357a3b48..bec0275e9b 100644
--- a/gui/src/shared/daemon-rpc-types.ts
+++ b/gui/src/shared/daemon-rpc-types.ts
@@ -279,9 +279,7 @@ export interface IShadowsocksProxySettings {
export interface IAppVersionInfo {
supported: boolean;
- latest: string;
- latestStable: string;
- latestBeta: string;
+ suggestedUpgrade?: string;
}
export interface ISettings {
diff --git a/gui/src/shared/ipc-event-channel.ts b/gui/src/shared/ipc-event-channel.ts
index c09b8d2a84..b020808e76 100644
--- a/gui/src/shared/ipc-event-channel.ts
+++ b/gui/src/shared/ipc-event-channel.ts
@@ -4,13 +4,14 @@ import * as uuid from 'uuid';
import { IGuiSettingsState } from './gui-settings-state';
-import { IAppUpgradeInfo, ICurrentAppVersionInfo } from '../main/index';
+import { ICurrentAppVersionInfo } from '../main/index';
import { IWindowShapeParameters } from '../main/window-controller';
import {
AccountToken,
BridgeSettings,
BridgeState,
IAccountData,
+ IAppVersionInfo,
ILocation,
IRelayList,
ISettings,
@@ -32,7 +33,7 @@ export interface IAppStateSnapshot {
location?: ILocation;
relayListPair: IRelayListPair;
currentVersion: ICurrentAppVersionInfo;
- upgradeVersion: IAppUpgradeInfo;
+ upgradeVersion: IAppVersionInfo;
guiSettings: IGuiSettingsState;
wireguardPublicKey?: IWireguardPublicKey;
}
@@ -267,7 +268,7 @@ export class IpcRendererEventChannel {
listen: listen(CURRENT_VERSION_CHANGED),
};
- public static upgradeVersion: IReceiver<IAppUpgradeInfo> = {
+ public static upgradeVersion: IReceiver<IAppVersionInfo> = {
listen: listen(UPGRADE_VERSION_CHANGED),
};
@@ -364,7 +365,7 @@ export class IpcMainEventChannel {
notify: sender(CURRENT_VERSION_CHANGED),
};
- public static upgradeVersion: ISender<IAppUpgradeInfo> = {
+ public static upgradeVersion: ISender<IAppVersionInfo> = {
notify: sender(UPGRADE_VERSION_CHANGED),
};
diff --git a/gui/src/shared/notifications/unsupported-version.ts b/gui/src/shared/notifications/unsupported-version.ts
index ed471bc586..fd2e0b5c72 100644
--- a/gui/src/shared/notifications/unsupported-version.ts
+++ b/gui/src/shared/notifications/unsupported-version.ts
@@ -11,7 +11,7 @@ import {
interface UnsupportedVersionNotificationContext {
supported: boolean;
consistent: boolean;
- nextUpgrade: string | null;
+ suggestedUpgrade?: string;
}
export class UnsupportedVersionNotificationProvider
@@ -19,21 +19,11 @@ export class UnsupportedVersionNotificationProvider
public constructor(private context: UnsupportedVersionNotificationContext) {}
public mayDisplay() {
- return this.context.consistent && !this.context.supported && this.context.nextUpgrade !== null;
+ return this.context.consistent && !this.context.supported;
}
public getSystemNotification(): SystemNotification {
- const message = sprintf(
- // TRANSLATORS: The system notification displayed to the user when the running app becomes unsupported.
- // TRANSLATORS: Available placeholder:
- // TRANSLATORS: %(version) - the newest available version of the app
- messages.pgettext(
- 'notifications',
- 'You are running an unsupported app version. Please upgrade to %(version)s now to ensure your security',
- ),
- { version: this.context.nextUpgrade },
- );
-
+ const message = this.getMessage();
return {
message,
critical: true,
@@ -44,16 +34,7 @@ export class UnsupportedVersionNotificationProvider
}
public getInAppNotification(): InAppNotification {
- const subtitle = sprintf(
- // TRANSLATORS: The in-app banner displayed to the user when the running app becomes unsupported.
- // TRANSLATORS: Available placeholders:
- // TRANSLATORS: %(version)s - the newest available version of the app
- messages.pgettext(
- 'in-app-notifications',
- 'You are running an unsupported app version. Please upgrade to %(version)s now to ensure your security',
- ),
- { version: this.context.nextUpgrade },
- );
+ const subtitle = this.getMessage();
return {
indicator: 'error',
@@ -62,4 +43,23 @@ export class UnsupportedVersionNotificationProvider
action: { type: 'open-url', url: links.download },
};
}
+
+ private getMessage(): string {
+ // TRANSLATORS: The in-app banner and system notification which are displayed to the user when the running app becomes unsupported.
+ let message = messages.pgettext('notifications', 'You are running an unsupported app version.');
+ if (this.context.suggestedUpgrade) {
+ message += ' ';
+ message += sprintf(
+ // TRANSLATORS: Appendix to the system notification and in-app banner about the app becoming unsupported with the suggested supported version.
+ // TRANSLATORS: Available placeholder:
+ // TRANSLATORS: %(version) - the newest available version of the app
+ messages.pgettext(
+ 'notifications',
+ 'Please upgrade to %(version)s now to ensure your security',
+ ),
+ { version: this.context.suggestedUpgrade },
+ );
+ }
+ return message;
+ }
}
diff --git a/gui/src/shared/notifications/update-available.ts b/gui/src/shared/notifications/update-available.ts
index 4d449bff28..d386765087 100644
--- a/gui/src/shared/notifications/update-available.ts
+++ b/gui/src/shared/notifications/update-available.ts
@@ -4,15 +4,14 @@ import { messages } from '../../shared/gettext';
import { InAppNotification, InAppNotificationProvider } from './notification';
interface UpdateAvailableNotificationContext {
- current: string;
- nextUpgrade: string | null;
+ suggestedUpgrade?: string;
}
export class UpdateAvailableNotificationProvider implements InAppNotificationProvider {
public constructor(private context: UpdateAvailableNotificationContext) {}
public mayDisplay() {
- return this.context.nextUpgrade !== null && this.context.nextUpgrade !== this.context.current;
+ return this.context.suggestedUpgrade ? true : false;
}
public getInAppNotification(): InAppNotification {
@@ -24,7 +23,7 @@ export class UpdateAvailableNotificationProvider implements InAppNotificationPro
'in-app-notifications',
'Install Mullvad VPN (%(version)s) to stay up to date',
),
- { version: this.context.nextUpgrade },
+ { version: this.context.suggestedUpgrade },
);
return {