Skip to content

Commit

Permalink
v4.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sidneys committed Nov 16, 2017
1 parent e5700fb commit e1a1d29
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 48 deletions.
1 change: 0 additions & 1 deletion .appveyor.yml
Expand Up @@ -38,7 +38,6 @@ deploy_script:

artifacts:
- path: build\output\*.exe
- path: build\output\*.yml

notifications:
- provider: Webhook
Expand Down
9 changes: 9 additions & 0 deletions RELEASENOTES.json
@@ -1,4 +1,13 @@
{
"4.0.4": {
"🍾 features": [
"Adds preference: application auto updates (#26)"
],
"👷 internals": [
"Upgrades `node_modules`",
"Upgrades `services`"
]
},
"4.0.3": {
"🍾 features": [
"Per-display enabling and disabling of Desktop Dimmer",
Expand Down
14 changes: 3 additions & 11 deletions app/scripts/main/components/application.js
Expand Up @@ -6,7 +6,7 @@
* Node
* @constant
*/
const EventEmitter = require('events');
const events = require('events');
const path = require('path');

/**
Expand All @@ -17,21 +17,12 @@ const path = require('path');
const appRootPath = require('app-root-path');
const platformTools = require('@sidneys/platform-tools');

/**
* Modules
* Electron
* @constant
*/
/* eslint-disable no-unused-vars */
const menubar = require(path.join(appRootPath['path'], 'app', 'scripts', 'main', 'components', 'menubar'));
/* eslint-enable */

/**
* Modules
* Configuration
*/
EventEmitter.defaultMaxListeners = Infinity;
appRootPath['setPath'](path.join(__dirname, '..', '..', '..', '..'));
events.EventEmitter.defaultMaxListeners = Infinity;
if (platformTools.isLinux) {
process.env.XDG_CURRENT_DESKTOP = 'Unity';
}
Expand All @@ -43,6 +34,7 @@ if (platformTools.isLinux) {
*/
/* eslint-disable no-unused-vars */
const globals = require(path.join(appRootPath['path'], 'app', 'scripts', 'main', 'components', 'globals'));
const menubar = require(path.join(appRootPath['path'], 'app', 'scripts', 'main', 'components', 'menubar'));
const updaterService = require(path.join(appRootPath['path'], 'app', 'scripts', 'main', 'services', 'updater-service'));
const debugService = require(path.join(appRootPath['path'], 'app', 'scripts', 'main', 'services', 'debug-service'));
const configurationManager = require(path.join(appRootPath['path'], 'app', 'scripts', 'main', 'managers', 'configuration-manager'));
Expand Down
4 changes: 3 additions & 1 deletion app/scripts/main/components/menubar.js
Expand Up @@ -76,9 +76,11 @@ let handleThemeChange = (browserWindow) => {
*/
class Menubar {
/**
* @constructs
* @constructor
*/
constructor() {
logger.debug('constructor');

this.menubar = electronMenubar({
alwaysOnTop: isDebug,
backgroundColor: platformTools.isMacOS ? void 0 : '#404040',
Expand Down
22 changes: 20 additions & 2 deletions app/scripts/main/managers/configuration-manager.js
Expand Up @@ -63,6 +63,26 @@ electronSettings.setPath(appSettingsFilepath);
* Configuration Items
*/
let configurationItems = {
/**
* appAutoUpdate
*/
appAutoUpdate: {
keypath: 'appAutoUpdate',
default: true,
init() {
logger.debug(this.keypath, 'init');
},
get() {
logger.debug(this.keypath, 'get');

return electronSettings.get(this.keypath);
},
set(value) {
logger.debug(this.keypath, 'set');

electronSettings.set(this.keypath, value);
}
},
/**
* appChangelog
*/
Expand Down Expand Up @@ -137,7 +157,6 @@ let configurationItems = {
},
/**
* appLogFile
* @type {String}
*/
appLogFile: {
keypath: 'appLogFile',
Expand All @@ -158,7 +177,6 @@ let configurationItems = {
},
/**
* overlayConfigurationDatabase
* @type {OverlayConfiguration[]}
*/
overlayConfigurationDatabase: {
keypath: 'overlayConfigurationDatabase',
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/main/managers/overlay-manager.js
Expand Up @@ -73,6 +73,8 @@ class OverlayManager extends events.EventEmitter {
* @constructor
*/
constructor() {
logger.debug('constructor');

super();
this.init();
}
Expand Down
4 changes: 3 additions & 1 deletion app/scripts/main/menus/tray-menu.js
Expand Up @@ -99,9 +99,11 @@ let createTrayMenuTemplate = () => {
class TrayMenu {
/**
* @param {Electron.MenuItemConstructorOptions[]} template - Menu template
* @constructs
* @constructor
*/
constructor(template) {
logger.debug('constructor');

this.template = template;
this.tray = getTray();
this.menu = Menu.buildFromTemplate(this.template);
Expand Down
85 changes: 57 additions & 28 deletions app/scripts/main/services/updater-service.js
Expand Up @@ -15,13 +15,7 @@ const path = require('path');
* @constant
*/
const electron = require('electron');
const { BrowserWindow } = electron || electron.remote;

/**
* Modules
* Configuration
*/
const app = global.menubar.menubar.app;
const { app, BrowserWindow } = electron;

/**
* Modules
Expand All @@ -41,7 +35,7 @@ const { autoUpdater } = require('electron-updater');
* @constant
*/
const dialogProvider = require(path.join(appRootPath, 'app', 'scripts', 'main', 'providers', 'dialog-provider'));
// const notificationProvider = require(path.join(appRootPath, 'app', 'scripts', 'main', 'providers', 'notification-provider'));
//const notificationProvider = require(path.join(appRootPath, 'app', 'scripts', 'main', 'providers', 'notification-provider'));
const configurationManager = require(path.join(appRootPath, 'app', 'scripts', 'main', 'managers', 'configuration-manager'));

/**
Expand All @@ -61,26 +55,32 @@ let getMainWindow = () => global.mainWindow;


/**
* Retrieve AppChangelog
* Retrieve appAutoUpdate
* @return {Boolean} - Yes / no
*/
let retrieveAppAutoUpdate = () => configurationManager('appAutoUpdate').get();

/**
* Retrieve appChangelog
* @return {String} - changelog
*/
let retrieveAppChangelog = () => configurationManager('appChangelog').get();

/**
* Store AppChangelog
* Store appChangelog
* @param {String} changelog - Changelog
* @return {void}
*/
let storeAppChangelog = (changelog) => configurationManager('appChangelog').set(changelog);

/**
* Retrieve AppLastVersion
* Retrieve appLastVersion
* @return {String} - Version
*/
let retrieveAppLastVersion = () => configurationManager('appLastVersion').get();

/**
* Store AppLastVersion
* Store appLastVersion
* @param {String} version - Version
* @return {void}
*/
Expand All @@ -94,9 +94,11 @@ let storeAppLastVersion = (version) => configurationManager('appLastVersion').se
*/
class UpdaterService {
/**
* @constructs
* @constructor
*/
constructor() {
logger.debug('constructor');

// Do not run with debug Electron application
if (process.defaultApp) { return; }

Expand Down Expand Up @@ -156,8 +158,8 @@ class UpdaterService {

this.isUpdating = true;

// const notification = notificationProvider.create({ title: `Update available for ${appProductName}`, subtitle: info.version });
// notification.show();
//const notification = notificationProvider.create({ title: `Update available for ${appProductName}`, subtitle: info.version });
//notification.show();
});

/**
Expand Down Expand Up @@ -196,8 +198,8 @@ class UpdaterService {

this.isUpdating = true;

// const notification = notificationProvider.create({ title: `Update ready to install for ${appProductName}`, subtitle: info.version });
// notification.show();
//const notification = notificationProvider.create({ title: `Update ready to install for ${appProductName}`, subtitle: info.version });
//notification.show();

if (!!info.releaseNotes) {
const releaseNotesPlaintext = removeMarkdown(info.releaseNotes);
Expand All @@ -222,7 +224,7 @@ class UpdaterService {
});
});

this.autoUpdater.checkForUpdates();
this.checkForUpdates();
}

/**
Expand Down Expand Up @@ -256,10 +258,43 @@ class UpdaterService {
dialogProvider.info(`${appProductName} has been updated to ${appCurrentVersion}`, `Update completed successfully.`);
}

// const notification = notificationProvider.create({ title: `Update installed for ${appProductName}`, subtitle: appCurrentVersion });
// notification.show();
//const notification = notificationProvider.create({ title: `Update installed for ${appProductName}`, subtitle: appCurrentVersion });
//notification.show();
}
}

/**
* Check if updater is ready
* @return {Boolean} - Yes / no
*/
isAvailable() {
logger.debug('isAvailable');

return Boolean(this.autoUpdater);
}

/**
* Check if currently updating
* @return {Boolean} - Yes / no
*/
isActive() {
logger.debug('isActive');

return Boolean(this.isUpdating);
}

/**
* Check for updates
*/
checkForUpdates() {
logger.debug('checkForUpdates');

if (!this.isAvailable()) { return; }
if (this.isActive()) { return; }

if (!retrieveAppAutoUpdate()) { return; }

this.autoUpdater.checkForUpdates();
}
}

Expand All @@ -283,15 +318,9 @@ let init = () => {
app.on('browser-window-focus', () => {
logger.debug('app#browser-window-focus');

if (!global.updaterService) { init(); }
if (!global.updaterService) { return; }

if (!global.updaterService.autoUpdater) { return; }

if (Boolean(global.updaterService.isUpdating) === false) {
if (global.updaterService.autoUpdater.checkForUpdates) {
global.updaterService.autoUpdater.checkForUpdates();
}
}
global.updaterService.checkForUpdates();
});

/**
Expand Down
10 changes: 10 additions & 0 deletions app/scripts/main/windows/overlay-configuration.js
@@ -1,6 +1,14 @@
'use strict';


/**
* Modules
* External
* @constant
*/
const logger = require('@sidneys/logger')({ write: true });


/**
* @typedef {String} OverlayAlpha - Floating-point alpha value
* @example '0.23'
Expand Down Expand Up @@ -53,6 +61,8 @@ class OverlayConfiguration {
* @constructor
*/
constructor(alpha = defaultAlpha, color = defaultColor, visibility = defaultVisibility) {
logger.debug('constructor');

this.alpha = alpha;
this.color = color;
this.visibility = visibility;
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/main/windows/overlay-window.js
Expand Up @@ -97,6 +97,8 @@ class OverlayWindow extends BrowserWindow {
* @constructor
*/
constructor(display) {
logger.debug('constructor');

super({
enableLargerThanScreen: true,
frame: false,
Expand Down
6 changes: 4 additions & 2 deletions app/scripts/renderer/preferences.js
Expand Up @@ -31,7 +31,6 @@ const logger = require('@sidneys/logger')({ write: true });
* @constant
*/
const configurationManager = remote.require(path.join(appRootPath, 'app', 'scripts', 'main', 'managers', 'configuration-manager'));
const globals = remote.require(path.join(appRootPath, 'app', 'scripts', 'main', 'components', 'globals'));


/**
Expand Down Expand Up @@ -63,7 +62,10 @@ let setVersion = (version) => versionTextElement.innerText = version.trim();
let renderPreferences = () => {
logger.debug('registerPreferences');

let preferenceKeyList = [ 'appLaunchOnStartup' ];
let preferenceKeyList = [
'appAutoUpdate',
'appLaunchOnStartup'
];

preferenceKeyList.forEach((keyName) => {
const preferenceInputElement = document.createElement('input');
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "desktop-dimmer",
"productName": "Desktop Dimmer",
"version": "4.0.3",
"version": "4.0.4",
"description": "Enables darker-than-dark Desktop dimming for your displays",
"license": "MIT",
"homepage": "https://sidneys.github.io/desktop-dimmer",
Expand Down

0 comments on commit e1a1d29

Please sign in to comment.