
* Create central logging module for adding prefixes to differentiate logs between modules * Turn logger into class * Merge'd * Rework to use class more intelligently * Fix modalView * Fix webContentEvents * Update src/main/app/intercom.ts Co-authored-by: Daniel Espino García <larkox@gmail.com> * Shorten prefixes on object creation --------- Co-authored-by: Daniel Espino García <larkox@gmail.com>
67 lines
1.7 KiB
TypeScript
67 lines
1.7 KiB
TypeScript
// Copyright (c) 2015-2016 Yuya Ochiai
|
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import AutoLaunch from 'auto-launch';
|
|
import {app} from 'electron';
|
|
import isDev from 'electron-is-dev';
|
|
|
|
import {Logger} from 'common/log';
|
|
|
|
const log = new Logger('AutoLauncher');
|
|
|
|
export class AutoLauncher {
|
|
appLauncher: AutoLaunch;
|
|
|
|
constructor() {
|
|
this.appLauncher = new AutoLaunch({
|
|
name: app.name,
|
|
isHidden: true,
|
|
});
|
|
}
|
|
|
|
async upgradeAutoLaunch() {
|
|
if (process.platform === 'darwin') {
|
|
return;
|
|
}
|
|
const appLauncher = new AutoLaunch({
|
|
name: app.name,
|
|
});
|
|
const enabled = await appLauncher.isEnabled();
|
|
if (enabled) {
|
|
await appLauncher.enable();
|
|
}
|
|
}
|
|
|
|
isEnabled() {
|
|
return this.appLauncher.isEnabled();
|
|
}
|
|
|
|
async enable() {
|
|
if (isDev) {
|
|
log.warn('In development mode, autostart config never effects');
|
|
return Promise.resolve(null);
|
|
}
|
|
const enabled = await this.isEnabled();
|
|
if (!enabled) {
|
|
return this.appLauncher.enable();
|
|
}
|
|
return Promise.resolve(null);
|
|
}
|
|
|
|
async disable() {
|
|
if (isDev) {
|
|
log.warn('In development mode, autostart config never effects');
|
|
return Promise.resolve(null);
|
|
}
|
|
const enabled = await this.isEnabled();
|
|
if (enabled) {
|
|
return this.appLauncher.disable();
|
|
}
|
|
return Promise.resolve(null);
|
|
}
|
|
}
|
|
|
|
const autoLauncher = new AutoLauncher();
|
|
export default autoLauncher;
|