Merge branch 'sysTraySetup' of https://github.com/roxanneskelly/hifi into sysTrayOsx

This commit is contained in:
Roxanne Skelly 2018-09-28 13:47:54 -07:00
commit 0c1bef6511
5 changed files with 49 additions and 42 deletions

View file

@ -945,7 +945,7 @@ Function HandlePostInstallOptions
Delete "$SMSTARTUP\@PRE_SANDBOX_CONSOLE_SHORTCUT_NAME@.lnk"
; make a startup shortcut in this user's current context
; use the console shortcut name regardless of server/interface install
; use the console shortcut name regardless of server/interface install
SetShellVarContext current
CreateShortCut "$SMSTARTUP\@CONSOLE_HF_SHORTCUT_NAME@.lnk" "$INSTDIR\@CONSOLE_INSTALL_SUBDIR@\@CONSOLE_WIN_EXEC_NAME@"

View file

@ -60,7 +60,10 @@ const HOME_CONTENT_URL = "http://cdn.highfidelity.com/content-sets/home-tutorial
const buildInfo = GetBuildInfo();
const NotificationState = {
UNNOTIFIED: 'unnotified',
NOTIFIED: 'notified'
};
// Update lock filepath
const UPDATER_LOCK_FILENAME = ".updating";
@ -324,12 +327,21 @@ const HifiNotifications = hfNotifications.HifiNotifications;
const HifiNotificationType = hfNotifications.NotificationType;
var pendingNotifications = {}
function notificationCallback(notificationType, pending = true) {
var notificationState = NotificationState.UNNOTIFIED;
function setNotificationState(notificationType, pending = true) {
pendingNotifications[notificationType] = pending;
notificationState = NotificationState.UNNOTIFIED;
for (var key in pendingNotifications) {
if (pendingNotifications[key]) {
notificationState = NotificationState.NOTIFIED;
break;
}
}
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
}
var trayNotifications = new HifiNotifications(userConfig, notificationCallback);
var trayNotifications = new HifiNotifications(userConfig, setNotificationState);
var LogWindow = function(ac, ds) {
this.ac = ac;
@ -389,7 +401,7 @@ var labels = {
type: 'checkbox',
checked: true,
click: function () {
trayNotifications.enable(!trayNotifications.enabled(), notificationCallback);
trayNotifications.enable(!trayNotifications.enabled(), setNotificationState);
userConfig.save(configPath);
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
}
@ -398,32 +410,28 @@ var labels = {
label: 'GoTo',
click: function () {
StartInterface("hifiapp:GOTO");
pendingNotifications[HifiNotificationType.GOTO] = false;
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
setNotificationState(HifiNotificationType.GOTO, false);
}
},
people: {
label: 'People',
click: function () {
StartInterface("hifiapp:PEOPLE");
pendingNotifications[HifiNotificationType.PEOPLE] = false;
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
setNotificationState(HifiNotificationType.PEOPLE, false);
}
},
wallet: {
label: 'Wallet',
click: function () {
StartInterface("hifiapp:WALLET");
pendingNotifications[HifiNotificationType.WALLET] = false;
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
setNotificationState(HifiNotificationType.WALLET, false);
}
},
marketplace: {
label: 'Market',
click: function () {
StartInterface("hifiapp:MARKET");
pendingNotifications[HifiNotificationType.MARKETPLACE] = false;
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
setNotificationState(HifiNotificationType.MARKETPLACE, false);
}
},
restart: {
@ -557,7 +565,7 @@ function updateLabels(serverState) {
function updateTrayMenu(serverState) {
if (tray) {
var menuArray = buildMenuArray(isShuttingDown ? null : serverState);
tray.setImage(trayIcons[serverState]);
tray.setImage(trayIcons[notificationState]);
tray.setContextMenu(Menu.buildFromTemplate(menuArray));
if (isShuttingDown) {
tray.setToolTip('High Fidelity - Shutting Down');
@ -777,9 +785,8 @@ function maybeShowSplash() {
const trayIconOS = (osType == "Darwin") ? "osx" : "win";
var trayIcons = {};
trayIcons[ProcessGroupStates.STARTED] = "console-tray-" + trayIconOS + ".png";
trayIcons[ProcessGroupStates.STOPPED] = "console-tray-" + trayIconOS + "-stopped.png";
trayIcons[ProcessGroupStates.STOPPING] = "console-tray-" + trayIconOS + "-stopping.png";
trayIcons[NotificationState.UNNOTIFIED] = "console-tray-" + trayIconOS + ".png";
trayIcons[NotificationState.NOTIFIED] = "console-tray-" + trayIconOS + "-stopped.png";
for (var key in trayIcons) {
var fullPath = path.join(__dirname, '../resources/' + trayIcons[key]);
var img = nativeImage.createFromPath(fullPath);
@ -892,7 +899,7 @@ app.on('ready', function() {
}
// Create tray icon
tray = new Tray(trayIcons[ProcessGroupStates.STOPPED]);
tray = new Tray(trayIcons[NotificationState.UNNOTIFIED]);
tray.setToolTip('High Fidelity');
tray.on('click', function() {

View file

@ -66,7 +66,7 @@ AccountInfo.prototype = {
case VariantTypes.USER_TYPE:
//user type
var userTypeName = this._parseByteArray().toString('ascii').slice(0,-1);
if (userTypeName == "DataServerAccountInfo") {
if (userTypeName === "DataServerAccountInfo") {
return this._parseDataServerAccountInfo();
}
else {
@ -77,7 +77,7 @@ AccountInfo.prototype = {
},
_parseByteArray: function () {
var length = this._parseUInt32();
if (length == 0xffffffff) {
if (length === 0xffffffff) {
return null;
}
var result = this.rawData.slice(this.parseOffset, this.parseOffset+length);
@ -91,7 +91,7 @@ AccountInfo.prototype = {
}
// length in bytes;
var length = this._parseUInt32();
if (length == 0xFFFFFFFF) {
if (length === 0xFFFFFFFF) {
return null;
}

View file

@ -15,9 +15,9 @@ const osType = os.type();
exports.getBuildInfo = function() {
var buildInfoPath = null;
if (osType == 'Windows_NT') {
if (osType === 'Windows_NT') {
buildInfoPath = path.join(path.dirname(process.execPath), 'build-info.json');
} else if (osType == 'Darwin') {
} else if (osType === 'Darwin') {
var contentPath = ".app/Contents/";
var contentEndIndex = __dirname.indexOf(contentPath);
@ -67,9 +67,9 @@ exports.startInterface = function(url) {
}
exports.isInterfaceRunning = function(done) {
if (osType == 'Windows_NT') {
if (osType === 'Windows_NT') {
var pInterface = new Process('interface', 'interface.exe');
} else if (osType == 'Darwin') {
} else if (osType === 'Darwin') {
var pInterface = new Process('interface', 'interface');
}
return pInterface.isRunning(done);
@ -78,13 +78,13 @@ exports.isInterfaceRunning = function(done) {
exports.getRootHifiDataDirectory = function(local) {
var organization = buildInfo.organization;
if (osType == 'Windows_NT') {
if (osType === 'Windows_NT') {
if (local) {
return path.resolve(osHomeDir(), 'AppData/Local', organization);
} else {
return path.resolve(osHomeDir(), 'AppData/Roaming', organization);
}
} else if (osType == 'Darwin') {
} else if (osType === 'Darwin') {
return path.resolve(osHomeDir(), 'Library/Application Support', organization);
} else {
return path.resolve(osHomeDir(), '.local/share/', organization);

View file

@ -51,8 +51,8 @@ HifiNotification.prototype = {
var app = null;
switch (this.type) {
case NotificationType.GOTO:
if (typeof(this.data) == "number") {
if (this.data == 1) {
if (typeof(this.data) === "number") {
if (this.data === 1) {
text = "You have " + this.data + " event invitation pending."
} else {
text = "You have " + this.data + " event invitations pending."
@ -67,8 +67,8 @@ HifiNotification.prototype = {
break;
case NotificationType.PEOPLE:
if (typeof(this.data) == "number") {
if (this.data == 1) {
if (typeof(this.data) === "number") {
if (this.data === 1) {
text = this.data + " of your connections is online."
} else {
text = this.data + " of your connections are online."
@ -83,8 +83,8 @@ HifiNotification.prototype = {
break;
case NotificationType.WALLET:
if (typeof(this.data) == "number") {
if (this.data == 1) {
if (typeof(this.data) === "number") {
if (this.data === 1) {
text = "You have " + this.data + " unread Wallet transaction.";
} else {
text = "You have " + this.data + " unread Wallet transactions.";
@ -99,8 +99,8 @@ HifiNotification.prototype = {
break;
case NotificationType.MARKETPLACE:
if (typeof(this.data) == "number") {
if (this.data == 1) {
if (typeof(this.data) === "number") {
if (this.data === 1) {
text = this.data + " of your purchased items has an update available.";
} else {
text = this.data + " of your purchased items have updates available.";
@ -124,7 +124,7 @@ HifiNotification.prototype = {
},
function (error, reason, metadata) {
if(_finished) {
if (osType == 'Darwin') {
if (osType === 'Darwin') {
setTimeout(_finished, OSX_CLICK_DELAY_TIMEOUT);
} else {
_finished();
@ -215,14 +215,14 @@ HifiNotifications.prototype = {
_showNotification: function () {
var _this = this;
if (osType == 'Darwin') {
if (osType === 'Darwin') {
this.pendingNotifications[0].show(function () {
// For OSX
// don't attempt to show the next notification
// Don't attempt to show the next notification
// until the current is clicked or times out
// as the OSX Notifier stuff will dismiss
// the previous notification immediately
// when a new one is submitted
// as the OSX Notifier stuff will dismiss the
// previous notification immediately when a
// new one is submitted
_this.pendingNotifications.shift();
if(_this.pendingNotifications.length > 0) {
_this._showNotification();
@ -238,7 +238,7 @@ HifiNotifications.prototype = {
},
_addNotification: function (notification) {
this.pendingNotifications.push(notification);
if(this.pendingNotifications.length == 1) {
if(this.pendingNotifications.length === 1) {
this._showNotification();
}
},