Auto-update server URL update

This commit is contained in:
sbenmoussati 2022-08-30 10:57:41 +02:00 committed by Salah Benmoussati
parent 03b137489d
commit 421d0fa2f4

View File

@ -9,7 +9,7 @@ import { whitelistHandler } from '../common/whitelist-handler';
import { config } from './config-handler';
import { windowHandler } from './window-handler';
const DEFAULT_AUTO_UPDATE_CHANNEL = 'client-bff/static/sda-update';
const DEFAULT_AUTO_UPDATE_CHANNEL = 'sda-update';
export class AutoUpdate {
public isUpdateAvailable: boolean = false;
@ -17,12 +17,7 @@ export class AutoUpdate {
public autoUpdater: MacUpdater | NsisUpdater | undefined = undefined;
constructor() {
const { autoUpdateChannel } = config.getConfigFields(['autoUpdateChannel']);
const opts: GenericServerOptions = {
provider: 'generic',
url: this.getUpdateUrl(),
channel: autoUpdateChannel || null,
};
const opts = this.getGenericServerOptions();
if (isMac) {
this.autoUpdater = new MacUpdater(opts);
} else if (isWindowsOS) {
@ -117,6 +112,8 @@ export class AutoUpdate {
public checkUpdates = async (): Promise<void> => {
logger.info('auto-update-handler: Checking for updates');
if (this.autoUpdater) {
const opts: GenericServerOptions = this.getGenericServerOptions();
this.autoUpdater.setFeedURL(opts);
const updateCheckResult = await this.autoUpdater.checkForUpdates();
logger.info('auto-update-handler: ', updateCheckResult);
}
@ -162,6 +159,16 @@ export class AutoUpdate {
return updateUrl;
};
private getGenericServerOptions = (): GenericServerOptions => {
const { autoUpdateChannel } = config.getConfigFields(['autoUpdateChannel']);
const opts: GenericServerOptions = {
provider: 'generic',
url: this.getUpdateUrl(),
channel: autoUpdateChannel || null,
};
return opts;
};
}
const autoUpdate = new AutoUpdate();