From 3468c93dd411467592e5f7ba0c3bfe851149dd38 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Tue, 29 Nov 2022 20:36:52 +0530 Subject: [PATCH] integrate mute update notification API --- src/pages/_app.tsx | 4 +++- src/services/electron/update.ts | 11 ++++++++--- src/types/electron/index.ts | 3 ++- src/utils/ui/index.tsx | 10 +++++++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 47a46e7f4..eb5ea72c3 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -141,7 +141,9 @@ export default function App({ Component, err }) { if (isElectron()) { const showUpdateDialog = (updateInfo: AppUpdateInfo) => { if (updateInfo.autoUpdatable) { - setDialogMessage(getUpdateReadyToInstallMessage()); + setDialogMessage( + getUpdateReadyToInstallMessage(updateInfo) + ); } else { setNotificationAttributes({ endIcon: , diff --git a/src/services/electron/update.ts b/src/services/electron/update.ts index 121facfd1..52641264a 100644 --- a/src/services/electron/update.ts +++ b/src/services/electron/update.ts @@ -21,9 +21,14 @@ class ElectronUpdateService { } } - skipAppVersion(version: string) { - if (this.electronAPIs?.skipAppVersion) { - this.electronAPIs.skipAppVersion(version); + skipAppUpdate(version: string) { + if (this.electronAPIs?.skipAppUpdate) { + this.electronAPIs.skipAppUpdate(version); + } + } + muteUpdateNotification(version: string) { + if (this.electronAPIs?.muteUpdateNotification) { + this.electronAPIs.muteUpdateNotification(version); } } } diff --git a/src/types/electron/index.ts b/src/types/electron/index.ts index e881667cb..9a75afc6f 100644 --- a/src/types/electron/index.ts +++ b/src/types/electron/index.ts @@ -74,7 +74,7 @@ export interface ElectronAPIs { showUpdateDialog: (updateInfo: AppUpdateInfo) => void ) => void; updateAndRestart: () => void; - skipAppVersion: (version: string) => void; + skipAppUpdate: (version: string) => void; getSentryUserID: () => Promise; getAppVersion: () => Promise; runFFmpegCmd: ( @@ -82,4 +82,5 @@ export interface ElectronAPIs { inputFile: File | ElectronFile, outputFileName: string ) => Promise; + muteUpdateNotification: (version: string) => void; } diff --git a/src/utils/ui/index.tsx b/src/utils/ui/index.tsx index a0fd26619..dc50389f1 100644 --- a/src/utils/ui/index.tsx +++ b/src/utils/ui/index.tsx @@ -45,16 +45,20 @@ export const getTrashFileMessage = (deleteFileHelper): DialogBoxAttributes => ({ close: { text: constants.CANCEL }, }); -export const getUpdateReadyToInstallMessage = (): DialogBoxAttributes => ({ +export const getUpdateReadyToInstallMessage = ( + updateInfo: AppUpdateInfo +): DialogBoxAttributes => ({ icon: , title: constants.UPDATE_AVAILABLE, content: constants.UPDATE_INSTALLABLE_MESSAGE, close: { text: constants.INSTALL_ON_NEXT_LAUNCH, variant: 'secondary', + action: () => ElectronUpdateService.updateAndRestart(), }, proceed: { - action: () => ElectronUpdateService.updateAndRestart(), + action: () => + ElectronUpdateService.muteUpdateNotification(updateInfo.version), text: constants.INSTALL_NOW, variant: 'accent', }, @@ -69,7 +73,7 @@ export const getUpdateAvailableForDownloadMessage = ( close: { text: constants.IGNORE_THIS_VERSION, variant: 'secondary', - action: () => ElectronUpdateService.skipAppVersion(updateInfo.version), + action: () => ElectronUpdateService.skipAppUpdate(updateInfo.version), }, proceed: { action: downloadApp,