Skip to content

Commit

Permalink
Merge pull request #16 from edanchenkov/feture/update-version
Browse files Browse the repository at this point in the history
Feture/update version
  • Loading branch information
edanchenkov authored Mar 27, 2020
2 parents 5c9c3b0 + 6b02ed9 commit a5508c2
Show file tree
Hide file tree
Showing 8 changed files with 2,906 additions and 2,281 deletions.
63 changes: 32 additions & 31 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ if (typeof __dirname !== 'undefined') {
/*
* Configs that should be saved locally must be listed here,
* also settings that user can implicitly change
* NOT VALID ANYMORE - NO LOCAL SETTINGS NO PREFERENCES PAGE!
* */
var userPreferences = {
alwaysOnTop : true,
Expand All @@ -20,64 +21,64 @@ var userPreferences = {
PIPModeByDefault : false,
highlightTray : true,
rememberBounds : true,
bounds : undefined,
theme : 'red-theme',
desktopMode : false
// bounds : { x : 0, y : 0, width : 400, height : 400 }
desktopMode : false,
};

var defaults = {
showOnRightClick : false,
userAgent : 'Mozilla/5.0 (Linux; U; Android 4.2; en-us; Nexus 10 Build/JVP15I) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30',
desktopUserAgent : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36',
externalLinks : false,
icon : path + '/icons/logo-icon-black-and-white/icon.iconset/icon_16x16.png',
iconPressed : path + '/icons/logo-icon-black-and-white-inverse/icon.iconset/icon_16x16.png',
width : 400,
height : 400,
preloadWindow : true,
showDockIcon : false
showOnRightClick: false,
// userAgent: 'Mozilla/5.0 (Linux; U; Android 4.2; en-us; Nexus 10 Build/JVP15I) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30',
// userAgent: 'Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-J737P) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/10.2 Chrome/71.0.3578.99 Mobile Safari/537.36',
userAgent: 'Mozilla/5.0 (Linux; U; Android 4.2; en-us; Nexus 10 Build/JVP15I) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/10.2 Chrome/71.0.3578.99 Mobile Safari/537.36',
desktopUserAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36',
externalLinks: false,
icon: path + '/icons/logo-icon-black-and-white/icon.iconset/icon_16x16.png',
iconPressed: path + '/icons/logo-icon-black-and-white-inverse/icon.iconset/icon_16x16.png',
preloadWindow: true,
showDockIcon: false,
browserWindow: {
width: 400,
height: 400,
webPreferences: {
nodeIntegration: true,
webviewTag: true
}
},
};


function AppConfig() {
var config = new Config();

if (typeof config.store === 'object') {

if (Object.keys(config.store).length !== Object.keys(userPreferences).length) {
for (var key in config.store) {
if (config.has(key)) {
if (!userPreferences.hasOwnProperty(key)) {
config.delete(key);
}
}
}
}

/*
* Save config file locally into config.json
* Ignore all local configs from now on
* */
config.set(Object.assign(userPreferences, config.store));
// This is another hack
userPreferences.desktopMode = config.store.desktopMode;
config.set(Object.assign(userPreferences, {}));
}


this.config = config;

Object.defineProperty(this, 'store', {
get : function () {
get: function () {
// Small hack to avoid issues with versioning and changes to preferences page
defaults.browserWindow.alwaysOnTop = userPreferences.alwaysOnTop;
return {
all : Object.assign(defaults, config.store),
userPreferences : config.store,
defaults : defaults
all: Object.assign(defaults, userPreferences),
userPreferences: userPreferences,
defaults: defaults
}
}
});

}

AppConfig.prototype = {
update : function (config) {
update: function (config) {
// This is another hack
this.config.set(config);
}
};
Expand Down
4 changes: 3 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var electron = require('electron');
var menubar = require('menubar');
const { menubar } = require('menubar');
var ipcMain = require('electron').ipcMain;

var AppConfig = require('./config.js');
Expand Down Expand Up @@ -170,6 +170,8 @@ mb.on('after-create-window', function () {
AppConfig.update({ bounds : mb.window.getBounds() });
};

// mb.window.openDevTools()

mb.window.on('resize', saveBounds, false);
mb.window.on('move', saveBounds, false);
});
Expand Down
Loading

0 comments on commit a5508c2

Please sign in to comment.