From eb4049860be011304398496c5e5a0abbc0679f8a Mon Sep 17 00:00:00 2001 From: Abhinav Date: Thu, 17 Nov 2022 14:54:57 +0530 Subject: [PATCH 1/5] add a cron to check for updates once every day --- src/services/appUpdater.ts | 10 ++++++++-- src/utils/main.ts | 8 ++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/services/appUpdater.ts b/src/services/appUpdater.ts index 90b4dd113..00db6f274 100644 --- a/src/services/appUpdater.ts +++ b/src/services/appUpdater.ts @@ -10,13 +10,19 @@ import { isPlatformMac } from '../utils/main'; import { logErrorSentry } from './sentry'; const FIVE_MIN_IN_MICROSECOND = 5 * 60 * 1000; +const ONE_DAY_IN_MICROSECOND = 1 * 24 * 60 * 60 * 1000; -export function setupAutoUpdater() { +export function setupAutoUpdater(mainWindow: BrowserWindow) { autoUpdater.logger = log; autoUpdater.autoDownload = false; + checkForUpdateAndNotify(mainWindow); + setInterval( + () => checkForUpdateAndNotify(mainWindow), + ONE_DAY_IN_MICROSECOND + ); } -export async function checkForUpdateAndNotify(mainWindow: BrowserWindow) { +async function checkForUpdateAndNotify(mainWindow: BrowserWindow) { try { log.debug('checkForUpdateAndNotify called'); const updateCheckResult = await autoUpdater.checkForUpdates(); diff --git a/src/utils/main.ts b/src/utils/main.ts index e814a2f09..4943dd934 100644 --- a/src/utils/main.ts +++ b/src/utils/main.ts @@ -8,15 +8,11 @@ import { isDev } from './common'; import { buildContextMenu, buildMenuBar } from './menu'; import autoLauncher from '../services/autoLauncher'; import { getHideDockIconPreference } from '../services/userPreference'; -import { - checkForUpdateAndNotify, - setupAutoUpdater, -} from '../services/appUpdater'; +import { setupAutoUpdater } from '../services/appUpdater'; export function handleUpdates(mainWindow: BrowserWindow) { if (!isDev) { - setupAutoUpdater(); - checkForUpdateAndNotify(mainWindow); + setupAutoUpdater(mainWindow); } } export function setupTrayItem(mainWindow: BrowserWindow) { From 7b317947a66917d3f04894c3ba4f695238d69c90 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Tue, 29 Nov 2022 20:30:30 +0530 Subject: [PATCH 2/5] add mute update notification api and rename skipAppVersion api to skipAppUpdate --- src/api/system.ts | 8 ++++++-- src/preload.ts | 6 ++++-- src/services/appUpdater.ts | 12 ++++++++++-- src/services/userPreference.ts | 9 +++++++++ src/stores/userPreferences.store.ts | 3 +++ src/types/index.ts | 1 + src/utils/ipcComms.ts | 11 ++++++++--- 7 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/api/system.ts b/src/api/system.ts index cba15edc7..fb4d68264 100644 --- a/src/api/system.ts +++ b/src/api/system.ts @@ -24,6 +24,10 @@ export const updateAndRestart = () => { ipcRenderer.send('update-and-restart'); }; -export const skipAppVersion = (version: string) => { - ipcRenderer.send('skip-app-version', version); +export const skipAppUpdate = (version: string) => { + ipcRenderer.send('skip-app-update', version); +}; + +export const muteUpdateNotification = (version: string) => { + ipcRenderer.send('mute-update-notification', version); }; diff --git a/src/preload.ts b/src/preload.ts index d51f20e92..2469f45ca 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -4,7 +4,8 @@ import { sendNotification, showOnTray, updateAndRestart, - skipAppVersion, + skipAppUpdate, + muteUpdateNotification, } from './api/system'; import { showUploadDirsDialog, @@ -98,8 +99,9 @@ windowObject['ElectronAPIs'] = { openLogDirectory, registerUpdateEventListener, updateAndRestart, - skipAppVersion, + skipAppUpdate, getSentryUserID, getAppVersion, runFFmpegCmd, + muteUpdateNotification, }; diff --git a/src/services/appUpdater.ts b/src/services/appUpdater.ts index 00db6f274..76116125e 100644 --- a/src/services/appUpdater.ts +++ b/src/services/appUpdater.ts @@ -4,7 +4,11 @@ import log from 'electron-log'; import { setIsAppQuitting, setIsUpdateAvailable } from '../main'; import semVerCmp from 'semver-compare'; import { AppUpdateInfo, GetFeatureFlagResponse } from '../types'; -import { getSkipAppVersion, setSkipAppVersion } from './userPreference'; +import { + getSkipAppVersion, + setMuteUpdateNotificationVersion, + setSkipAppVersion, +} from './userPreference'; import fetch from 'node-fetch'; import { isPlatformMac } from '../utils/main'; import { logErrorSentry } from './sentry'; @@ -97,10 +101,14 @@ export function getAppVersion() { return `v${app.getVersion()}`; } -export function skipAppVersion(version: string) { +export function skipAppUpdate(version: string) { setSkipAppVersion(version); } +export function muteUpdateNotification(version: string) { + setMuteUpdateNotificationVersion(version); +} + async function getDesktopCutoffVersion() { try { const featureFlags = ( diff --git a/src/services/userPreference.ts b/src/services/userPreference.ts index 5746c2ae6..82e42915e 100644 --- a/src/services/userPreference.ts +++ b/src/services/userPreference.ts @@ -11,6 +11,15 @@ export function setHideDockIconPreference(shouldHideDockIcon: boolean) { export function getSkipAppVersion() { return userPreferencesStore.get('skipAppVersion'); } + export function setSkipAppVersion(version: string) { userPreferencesStore.set('skipAppVersion', version); } + +export function getMuteUpdateNotificationVersion() { + return userPreferencesStore.get('muteUpdateNotificationVersion'); +} + +export function setMuteUpdateNotificationVersion(version: string) { + userPreferencesStore.set('muteUpdateNotificationVersion', version); +} diff --git a/src/stores/userPreferences.store.ts b/src/stores/userPreferences.store.ts index 09e7ce2fe..06ce9f05a 100644 --- a/src/stores/userPreferences.store.ts +++ b/src/stores/userPreferences.store.ts @@ -8,6 +8,9 @@ const userPreferencesSchema: Schema = { skipAppVersion: { type: 'string', }, + muteUpdateNotificationVersion: { + type: 'string', + }, }; export const userPreferencesStore = new Store({ diff --git a/src/types/index.ts b/src/types/index.ts index a7d26186e..f8aeb056b 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -57,6 +57,7 @@ export interface SafeStorageStoreType { export interface UserPreferencesType { hideDockIcon: boolean; skipAppVersion: string; + muteUpdateNotificationVersion: string; } export interface AppUpdateInfo { diff --git a/src/utils/ipcComms.ts b/src/utils/ipcComms.ts index daa92f6c2..f4a17523a 100644 --- a/src/utils/ipcComms.ts +++ b/src/utils/ipcComms.ts @@ -17,7 +17,8 @@ import { getDirFilePaths } from '../services/fs'; import { convertHEIC } from '../services/heicConvertor'; import { getAppVersion, - skipAppVersion, + muteUpdateNotification, + skipAppUpdate, updateAndRestart, } from '../services/appUpdater'; import { @@ -120,8 +121,12 @@ export default function setupIpcComs( ipcMain.on('update-and-restart', () => { updateAndRestart(); }); - ipcMain.on('skip-app-version', (_, version) => { - skipAppVersion(version); + ipcMain.on('skip-app-update', (_, version) => { + skipAppUpdate(version); + }); + + ipcMain.on('mute-update-notification', (_, version) => { + muteUpdateNotification(version); }); ipcMain.handle('get-sentry-id', () => { return getSentryUserID(); From df00fd72150d697927c4ccc1d3e072abc1bf3be6 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Tue, 29 Nov 2022 20:31:04 +0530 Subject: [PATCH 3/5] update UI --- ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui b/ui index 6320f0295..eeaf9a17d 160000 --- a/ui +++ b/ui @@ -1 +1 @@ -Subproject commit 6320f0295d811570adad53a32ce94beb912fa9f9 +Subproject commit eeaf9a17d22874635e3154b84382f7c5aa282760 From 595fc2a18534b51cb9c7a094b8cbdb06807a4595 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Tue, 29 Nov 2022 20:37:04 +0530 Subject: [PATCH 4/5] update UI --- ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui b/ui index eeaf9a17d..3468c93dd 160000 --- a/ui +++ b/ui @@ -1 +1 @@ -Subproject commit eeaf9a17d22874635e3154b84382f7c5aa282760 +Subproject commit 3468c93dd411467592e5f7ba0c3bfe851149dd38 From 2e25e522fa5d263d77ff82d343f8936f9656b7c8 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sat, 21 Jan 2023 09:55:53 +0530 Subject: [PATCH 5/5] update UI --- ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui b/ui index 7ea527a8d..f4f1de08e 160000 --- a/ui +++ b/ui @@ -1 +1 @@ -Subproject commit 7ea527a8d2d1365dff657ff3bbb7c2d97c44e97f +Subproject commit f4f1de08eb8556d598d75b79a4473a1f02e8165b