Skip to content

Commit

Permalink
v3.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sidneys committed Jan 29, 2017
1 parent b1757a4 commit 3d4c33b
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 58 deletions.
26 changes: 12 additions & 14 deletions app/scripts/renderer/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ const { remote } = require('electron');
*/
const appRootPath = require('app-root-path').path;
const editorContextMenu = remote.require('electron-editor-context-menu');
const isOnline = require('is-online');

/**
* Modules
* Internal
* @global
* @constant
*/
const connectivityService = require(path.join(appRootPath, 'app', 'scripts', 'services', 'connectivity-service'));
const isDebug = require(path.join(appRootPath, 'lib', 'is-debug'));
const logger = require(path.join(appRootPath, 'lib', 'logger'))({ writeToFile: true });
const platformHelper = require(path.join(appRootPath, 'lib', 'platform-helper'));
Expand All @@ -47,6 +47,11 @@ const settings = require(path.join(appRootPath, 'app', 'scripts', 'configuration
*/
const appIcon = path.join(appRootPath, 'icons', platformHelper.type, `icon${platformHelper.iconImageExtension(platformHelper.type)}`);

/**
* @global
* @constant
*/
const defaultInterval = 5000;

//noinspection JSUnusedLocalSymbols
/**
Expand All @@ -58,13 +63,6 @@ const pbClipboard = require(path.join(appRootPath, 'app', 'scripts', 'renderer',
const pbPush = require(path.join(appRootPath, 'app', 'scripts', 'renderer', 'pushbullet', 'push')); // jshint ignore:line


/**
* @global
* @default
*/
let defaultInterval = 1000;


/**
* @global
*/
Expand Down Expand Up @@ -246,13 +244,13 @@ let registerWebsocketListeners = () => {
};

/**
* Initialize
* Init
*/
let initialize = () => {
/** @listens connectivityService#on */
let init = () => {
logger.debug('inject', 'init()');

connectivityService.once('online', () => {
logger.debug('inject', 'connectivityService#once');
isOnline({ hostnames: [ 'www.pushbullet.com' ] }).then(online => {
logger.debug('inject', 'init()', 'isOnline');

registerNavigationOptimizations();
registerErrorProxyobject();
Expand Down Expand Up @@ -302,7 +300,7 @@ window.addEventListener('load', () => {
pb = window.pb;
onecup = window.onecup;

initialize();
init();

clearInterval(pollingInterval);
}, defaultInterval, this);
Expand Down
38 changes: 19 additions & 19 deletions app/scripts/renderer/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ let dismissSpinner = function() {
};


/** @listens connectivityService#on */
connectivityService.on('online', () => {
logger.debug('webview', 'connectivityService:online');

dismissSpinner();
});

/** @listens connectivityService#on */
connectivityService.on('offline', () => {
logger.debug('webview', 'connectivityService:offline');

presentSpinner();
});


/** @listens webview:dom-ready */
webview.addEventListener('dom-ready', () => {
// Register Platform
Expand All @@ -94,20 +109,20 @@ webview.addEventListener('dom-ready', () => {

/** @listens webview:did-fail-load */
webview.addEventListener('did-fail-load', () => {
logger.debug('webview', 'webview:did-fail-load');

if (!connectivityService.online) {
presentSpinner();
}

logger.devtools('connectivityService', connectivityService.online);
});

/** @listens webview:did-finish-load */
webview.addEventListener('did-finish-load', () => {
logger.debug('webview', 'webview:did-finish-load');

if (connectivityService.online) {
dismissSpinner();
}

logger.devtools('connectivityService', connectivityService.online);
});

/** @listens webview:new-window */
Expand Down Expand Up @@ -146,18 +161,3 @@ webview.addEventListener('load-commit', (ev) => {

});

/** @listens connectivityService#on */
connectivityService.on('online', () => {
logger.debug('webview', 'connectivityService:online');

dismissSpinner();
});

/** @listens connectivityService#on */
connectivityService.on('offline', () => {
logger.debug('webview', 'connectivityService:offline');

presentSpinner();
});


19 changes: 11 additions & 8 deletions app/scripts/services/connectivity-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ const defaultInterval = 5000;
* Singleton
* @global
*/
let connectivity;
global.connectivityService = null;

/**
* Connectivity Monitor
* Connectivity
* @class
* @extends EventEmitter
*/
Expand Down Expand Up @@ -107,12 +107,14 @@ class Connectivity extends EventEmitter {


/**
* Initializer
* Init
*/
let init = () => {
logger.debug('connectivity-service', 'create()');

connectivity = new Connectivity();
logger.debug('connectivity-service', 'init()');

if (!global.connectivityService) {
global.connectivityService = new Connectivity();
}
};

/**
Expand All @@ -121,8 +123,9 @@ let init = () => {
let get = () => {
logger.debug('connectivity-service', 'get()');

if (!connectivity) { return; }
return connectivity;
if (global.connectivityService) {
return global.connectivityService;
}
};


Expand Down
5 changes: 3 additions & 2 deletions app/scripts/services/notification-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ const appProductName = packageJson.productName || packageJson.name;
* @param {String} message - Title
*/
let showNotification = (message) => {
let options = {
const options = {
body: message,
icon: appIcon,
silent: true
};
const code = `new Notification('${appProductName}', ${JSON.stringify(options)});`;

BrowserWindow.getAllWindows()[0].webContents.executeJavaScript(`new Notification('${appProductName}', ${JSON.stringify(options)});`, true).then(() => {});
BrowserWindow.getAllWindows()[0].webContents.executeJavaScript(code, true).then(() => {});
};


Expand Down
15 changes: 9 additions & 6 deletions app/scripts/services/snoozer-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ global.snoozeUntil = 0;
* Singleton
* @global
*/
let snoozer;
global.snoozerService = null;

/**
* Snoozer
Expand Down Expand Up @@ -128,12 +128,14 @@ class Snoozer extends EventEmitter {


/**
* Initializer
* Init
*/
let init = () => {
logger.debug('snoozer-service', 'create()');
logger.debug('snoozer-service', 'init()');

snoozer = new Snoozer();
if (!global.snoozerService) {
global.snoozerService = new Snoozer();
}
};

/**
Expand All @@ -142,8 +144,9 @@ let init = () => {
let get = () => {
logger.debug('snoozer-service', 'get()');

if (!snoozer) { return; }
return snoozer;
if (global.snoozerService) {
return global.snoozerService;
}
};


Expand Down
19 changes: 11 additions & 8 deletions app/scripts/services/updater-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ let isCheckingOrInstallingUpdates = false;
* Singleton
* @global
*/
let updateManager;
global.updaterService = null;

/**
* Update Manager
* Updater
* @class
* @returns autoUpdater
*/
class UpdateManager {
class Updater {
constructor() {
if (platformHelper.isLinux) { return; }

Expand Down Expand Up @@ -184,15 +184,17 @@ let bumpVersion = () => {


/**
* Initializer
* Init
*/
let init = () => {
logger.debug('updater-service', 'create()');
logger.debug('updater-service', 'init()');

if (isDebug) { return; }

try {
updateManager = new UpdateManager();
if (!global.updaterService) {
global.updaterService = new Updater();
}
} catch (error) {
logger.error('updater-service', error.message);
}
Expand All @@ -206,8 +208,9 @@ let init = () => {
let get = () => {
logger.debug('updater-service', 'get()');

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


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pb-for-desktop",
"productName": "PB for Desktop",
"version": "3.5.3",
"version": "3.6.0",
"description": "PushBullet desktop application for macOS, Windows and Linux",
"license": "MIT",
"homepage": "https://sidneys.github.io/pb-for-desktop",
Expand Down

0 comments on commit 3d4c33b

Please sign in to comment.