mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-04 05:53:21 +00:00 
			
		
		
		
	typescript: Migrate autoupdater to typescript.
This commit is contained in:
		@@ -1,18 +1,20 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
const { app, dialog, shell } = require('electron');
 | 
					import { app, dialog, shell } from 'electron';
 | 
				
			||||||
const { autoUpdater } = require('electron-updater');
 | 
					import { autoUpdater } from 'electron-updater';
 | 
				
			||||||
const isDev = require('electron-is-dev');
 | 
					import * as isDev from 'electron-is-dev';
 | 
				
			||||||
 | 
					import log from 'electron-log';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const ConfigUtil = require('./../renderer/js/utils/config-util.js');
 | 
					import { linuxUpdateNotification } from './linuxupdater';	// Required only in case of linux
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function appUpdater(updateFromMenu = false) {
 | 
					import ConfigUtil = require('../renderer/js/utils/config-util');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export function appUpdater(updateFromMenu = false): void {
 | 
				
			||||||
	// Don't initiate auto-updates in development
 | 
						// Don't initiate auto-updates in development
 | 
				
			||||||
	if (isDev) {
 | 
						if (isDev) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (process.platform === 'linux' && !process.env.APPIMAGE) {
 | 
						if (process.platform === 'linux' && !process.env.APPIMAGE) {
 | 
				
			||||||
		const { linuxUpdateNotification } = require('./linuxupdater');
 | 
					 | 
				
			||||||
		linuxUpdateNotification();
 | 
							linuxUpdateNotification();
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -23,8 +25,6 @@ function appUpdater(updateFromMenu = false) {
 | 
				
			|||||||
	const LogsDir = `${app.getPath('userData')}/Logs`;
 | 
						const LogsDir = `${app.getPath('userData')}/Logs`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Log whats happening
 | 
						// Log whats happening
 | 
				
			||||||
	const log = require('electron-log');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	log.transports.file.file = `${LogsDir}/updates.log`;
 | 
						log.transports.file.file = `${LogsDir}/updates.log`;
 | 
				
			||||||
	log.transports.file.level = 'info';
 | 
						log.transports.file.level = 'info';
 | 
				
			||||||
	autoUpdater.logger = log;
 | 
						autoUpdater.logger = log;
 | 
				
			||||||
@@ -84,7 +84,6 @@ Current Version: ${app.getVersion()}`
 | 
				
			|||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Ask the user if update is available
 | 
						// Ask the user if update is available
 | 
				
			||||||
	// eslint-disable-next-line no-unused-vars
 | 
					 | 
				
			||||||
	autoUpdater.on('update-downloaded', event => {
 | 
						autoUpdater.on('update-downloaded', event => {
 | 
				
			||||||
		// Ask user to update the app
 | 
							// Ask user to update the app
 | 
				
			||||||
		dialog.showMessageBox({
 | 
							dialog.showMessageBox({
 | 
				
			||||||
@@ -106,7 +105,3 @@ Current Version: ${app.getVersion()}`
 | 
				
			|||||||
	// Init for updates
 | 
						// Init for updates
 | 
				
			||||||
	autoUpdater.checkForUpdates();
 | 
						autoUpdater.checkForUpdates();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
module.exports = {
 | 
					 | 
				
			||||||
	appUpdater
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user