Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dismiss update functionality #7861

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions desktop/packages/mullvad-vpn/src/main/gui-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const settingsSchema: Record<keyof IGuiSettingsState, string> = {
unpinnedWindow: 'boolean',
browsedForSplitTunnelingApplications: 'Array<string>',
changelogDisplayedForVersion: 'string',
updateDismissedForVersion: 'string',
animateMap: 'boolean',
};

Expand All @@ -26,6 +27,7 @@ const defaultSettings: IGuiSettingsState = {
unpinnedWindow: process.platform !== 'win32' && process.platform !== 'darwin',
browsedForSplitTunnelingApplications: [],
changelogDisplayedForVersion: '',
updateDismissedForVersion: '',
animateMap: true,
};

Expand Down Expand Up @@ -116,6 +118,16 @@ export default class GuiSettings {
: this.stateValue.changelogDisplayedForVersion;
}

set updateDismissedForVersion(newValue: string | undefined) {
this.changeStateAndNotify({ ...this.stateValue, updateDismissedForVersion: newValue ?? '' });
}

get updateDismissedForVersion(): string | undefined {
return this.stateValue.updateDismissedForVersion === ''
? undefined
: this.stateValue.updateDismissedForVersion;
}

set animateMap(newValue: boolean) {
this.changeStateAndNotify({ ...this.stateValue, animateMap: newValue });
}
Expand Down
4 changes: 4 additions & 0 deletions desktop/packages/mullvad-vpn/src/main/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export default class Settings implements Readonly<ISettings> {
IpcMainEventChannel.currentVersion.handleDisplayedChangelog(() => {
this.guiSettings.changelogDisplayedForVersion = this.currentVersion.gui;
});

IpcMainEventChannel.upgradeVersion.handleDismissedUpgrade((version: string) => {
this.guiSettings.updateDismissedForVersion = version;
});
}

public get all() {
Expand Down
6 changes: 6 additions & 0 deletions desktop/packages/mullvad-vpn/src/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,12 @@ export default class AppRenderer {
IpcRendererEventChannel.currentVersion.displayedChangelog();
};

public setDismissedUpgrade = (): void => {
IpcRendererEventChannel.upgradeVersion.dismissedUpgrade(
this.reduxStore.getState().version.suggestedUpgrade ?? '',
);
};

public setNavigationHistory(history: IHistoryObject) {
IpcRendererEventChannel.navigation.setHistory(history);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const initialState: ISettingsReduxState = {
unpinnedWindow: window.env.platform !== 'win32' && window.env.platform !== 'darwin',
browsedForSplitTunnelingApplications: [],
changelogDisplayedForVersion: '',
updateDismissedForVersion: '',
animateMap: true,
},
relaySettings: {
Expand Down
4 changes: 4 additions & 0 deletions desktop/packages/mullvad-vpn/src/shared/gui-settings-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export interface IGuiSettingsState {
// changelog after upgrade.
changelogDisplayedForVersion: string;

// The last version that the update dialog was dismissed for. This is used to determine
// whether to show the update notification.
updateDismissedForVersion: string;

// Tells the app whether or not to show the map in the main view.
animateMap: boolean;
}
1 change: 1 addition & 0 deletions desktop/packages/mullvad-vpn/src/shared/ipc-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const ipcSchema = {
},
upgradeVersion: {
'': notifyRenderer<IAppVersionInfo>(),
dismissedUpgrade: send<string>(),
},
app: {
quit: send<void>(),
Expand Down
1 change: 1 addition & 0 deletions desktop/packages/mullvad-vpn/test/e2e/setup/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ApplicationMain {
unpinnedWindow: process.platform !== 'win32' && process.platform !== 'darwin',
browsedForSplitTunnelingApplications: [],
changelogDisplayedForVersion: '',
updateDismissedForVersion: '',
animateMap: true,
};

Expand Down