Merge pull request #106 from ente-io/check-for-update-every-day-once
add a cron to check for updates once every day
This commit is contained in:
commit
4e81618142
|
@ -24,6 +24,10 @@ export const updateAndRestart = () => {
|
||||||
ipcRenderer.send('update-and-restart');
|
ipcRenderer.send('update-and-restart');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const skipAppVersion = (version: string) => {
|
export const skipAppUpdate = (version: string) => {
|
||||||
ipcRenderer.send('skip-app-version', version);
|
ipcRenderer.send('skip-app-update', version);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const muteUpdateNotification = (version: string) => {
|
||||||
|
ipcRenderer.send('mute-update-notification', version);
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,8 @@ import {
|
||||||
sendNotification,
|
sendNotification,
|
||||||
showOnTray,
|
showOnTray,
|
||||||
updateAndRestart,
|
updateAndRestart,
|
||||||
skipAppVersion,
|
skipAppUpdate,
|
||||||
|
muteUpdateNotification,
|
||||||
} from './api/system';
|
} from './api/system';
|
||||||
import {
|
import {
|
||||||
showUploadDirsDialog,
|
showUploadDirsDialog,
|
||||||
|
@ -100,9 +101,10 @@ windowObject['ElectronAPIs'] = {
|
||||||
openLogDirectory,
|
openLogDirectory,
|
||||||
registerUpdateEventListener,
|
registerUpdateEventListener,
|
||||||
updateAndRestart,
|
updateAndRestart,
|
||||||
skipAppVersion,
|
skipAppUpdate,
|
||||||
getSentryUserID,
|
getSentryUserID,
|
||||||
getAppVersion,
|
getAppVersion,
|
||||||
runFFmpegCmd,
|
runFFmpegCmd,
|
||||||
|
muteUpdateNotification,
|
||||||
generateImageThumbnail,
|
generateImageThumbnail,
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,20 +4,30 @@ import log from 'electron-log';
|
||||||
import { setIsAppQuitting, setIsUpdateAvailable } from '../main';
|
import { setIsAppQuitting, setIsUpdateAvailable } from '../main';
|
||||||
import semVerCmp from 'semver-compare';
|
import semVerCmp from 'semver-compare';
|
||||||
import { AppUpdateInfo, GetFeatureFlagResponse } from '../types';
|
import { AppUpdateInfo, GetFeatureFlagResponse } from '../types';
|
||||||
import { getSkipAppVersion, setSkipAppVersion } from './userPreference';
|
import {
|
||||||
|
getSkipAppVersion,
|
||||||
|
setMuteUpdateNotificationVersion,
|
||||||
|
setSkipAppVersion,
|
||||||
|
} from './userPreference';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import { logErrorSentry } from './sentry';
|
import { logErrorSentry } from './sentry';
|
||||||
import ElectronLog from 'electron-log';
|
import ElectronLog from 'electron-log';
|
||||||
import { isPlatform } from '../utils/main';
|
import { isPlatform } from '../utils/main';
|
||||||
|
|
||||||
const FIVE_MIN_IN_MICROSECOND = 5 * 60 * 1000;
|
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.logger = log;
|
||||||
autoUpdater.autoDownload = false;
|
autoUpdater.autoDownload = false;
|
||||||
|
checkForUpdateAndNotify(mainWindow);
|
||||||
|
setInterval(
|
||||||
|
() => checkForUpdateAndNotify(mainWindow),
|
||||||
|
ONE_DAY_IN_MICROSECOND
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkForUpdateAndNotify(mainWindow: BrowserWindow) {
|
async function checkForUpdateAndNotify(mainWindow: BrowserWindow) {
|
||||||
try {
|
try {
|
||||||
log.debug('checkForUpdateAndNotify called');
|
log.debug('checkForUpdateAndNotify called');
|
||||||
const updateCheckResult = await autoUpdater.checkForUpdates();
|
const updateCheckResult = await autoUpdater.checkForUpdates();
|
||||||
|
@ -93,10 +103,14 @@ export function getAppVersion() {
|
||||||
return `v${app.getVersion()}`;
|
return `v${app.getVersion()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function skipAppVersion(version: string) {
|
export function skipAppUpdate(version: string) {
|
||||||
setSkipAppVersion(version);
|
setSkipAppVersion(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function muteUpdateNotification(version: string) {
|
||||||
|
setMuteUpdateNotificationVersion(version);
|
||||||
|
}
|
||||||
|
|
||||||
async function getDesktopCutoffVersion() {
|
async function getDesktopCutoffVersion() {
|
||||||
try {
|
try {
|
||||||
const featureFlags = (
|
const featureFlags = (
|
||||||
|
|
|
@ -11,6 +11,15 @@ export function setHideDockIconPreference(shouldHideDockIcon: boolean) {
|
||||||
export function getSkipAppVersion() {
|
export function getSkipAppVersion() {
|
||||||
return userPreferencesStore.get('skipAppVersion');
|
return userPreferencesStore.get('skipAppVersion');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setSkipAppVersion(version: string) {
|
export function setSkipAppVersion(version: string) {
|
||||||
userPreferencesStore.set('skipAppVersion', version);
|
userPreferencesStore.set('skipAppVersion', version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getMuteUpdateNotificationVersion() {
|
||||||
|
return userPreferencesStore.get('muteUpdateNotificationVersion');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setMuteUpdateNotificationVersion(version: string) {
|
||||||
|
userPreferencesStore.set('muteUpdateNotificationVersion', version);
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@ const userPreferencesSchema: Schema<UserPreferencesType> = {
|
||||||
skipAppVersion: {
|
skipAppVersion: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
|
muteUpdateNotificationVersion: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const userPreferencesStore = new Store({
|
export const userPreferencesStore = new Store({
|
||||||
|
|
|
@ -57,6 +57,7 @@ export interface SafeStorageStoreType {
|
||||||
export interface UserPreferencesType {
|
export interface UserPreferencesType {
|
||||||
hideDockIcon: boolean;
|
hideDockIcon: boolean;
|
||||||
skipAppVersion: string;
|
skipAppVersion: string;
|
||||||
|
muteUpdateNotificationVersion: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppUpdateInfo {
|
export interface AppUpdateInfo {
|
||||||
|
|
|
@ -20,7 +20,8 @@ import {
|
||||||
} from '../services/imageProcessor';
|
} from '../services/imageProcessor';
|
||||||
import {
|
import {
|
||||||
getAppVersion,
|
getAppVersion,
|
||||||
skipAppVersion,
|
muteUpdateNotification,
|
||||||
|
skipAppUpdate,
|
||||||
updateAndRestart,
|
updateAndRestart,
|
||||||
} from '../services/appUpdater';
|
} from '../services/appUpdater';
|
||||||
import { deleteTempFile, runFFmpegCmd } from '../services/ffmpeg';
|
import { deleteTempFile, runFFmpegCmd } from '../services/ffmpeg';
|
||||||
|
@ -120,8 +121,12 @@ export default function setupIpcComs(
|
||||||
ipcMain.on('update-and-restart', () => {
|
ipcMain.on('update-and-restart', () => {
|
||||||
updateAndRestart();
|
updateAndRestart();
|
||||||
});
|
});
|
||||||
ipcMain.on('skip-app-version', (_, version) => {
|
ipcMain.on('skip-app-update', (_, version) => {
|
||||||
skipAppVersion(version);
|
skipAppUpdate(version);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('mute-update-notification', (_, version) => {
|
||||||
|
muteUpdateNotification(version);
|
||||||
});
|
});
|
||||||
ipcMain.handle('get-sentry-id', () => {
|
ipcMain.handle('get-sentry-id', () => {
|
||||||
return getSentryUserID();
|
return getSentryUserID();
|
||||||
|
|
|
@ -8,17 +8,13 @@ import { isDev } from './common';
|
||||||
import { buildContextMenu, buildMenuBar } from './menu';
|
import { buildContextMenu, buildMenuBar } from './menu';
|
||||||
import autoLauncher from '../services/autoLauncher';
|
import autoLauncher from '../services/autoLauncher';
|
||||||
import { getHideDockIconPreference } from '../services/userPreference';
|
import { getHideDockIconPreference } from '../services/userPreference';
|
||||||
import {
|
import { setupAutoUpdater } from '../services/appUpdater';
|
||||||
checkForUpdateAndNotify,
|
|
||||||
setupAutoUpdater,
|
|
||||||
} from '../services/appUpdater';
|
|
||||||
import ElectronLog from 'electron-log';
|
import ElectronLog from 'electron-log';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
export function handleUpdates(mainWindow: BrowserWindow) {
|
export function handleUpdates(mainWindow: BrowserWindow) {
|
||||||
if (!isDev) {
|
if (!isDev) {
|
||||||
setupAutoUpdater();
|
setupAutoUpdater(mainWindow);
|
||||||
checkForUpdateAndNotify(mainWindow);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export function setupTrayItem(mainWindow: BrowserWindow) {
|
export function setupTrayItem(mainWindow: BrowserWindow) {
|
||||||
|
|
2
ui
2
ui
|
@ -1 +1 @@
|
||||||
Subproject commit 86a7f1cdab5c3a9a2cfbd0daecb9f7e1dd06660e
|
Subproject commit f4f1de08eb8556d598d75b79a4473a1f02e8165b
|
Loading…
Reference in a new issue