mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
Merge pull request #14179 from roxanneskelly/sysTraySubmenus
Sys tray submenus
This commit is contained in:
commit
9ccdf74235
2 changed files with 98 additions and 24 deletions
|
@ -338,13 +338,15 @@ const HifiNotificationType = hfNotifications.NotificationType;
|
||||||
var pendingNotifications = {}
|
var pendingNotifications = {}
|
||||||
var notificationState = NotificationState.UNNOTIFIED;
|
var notificationState = NotificationState.UNNOTIFIED;
|
||||||
|
|
||||||
function setNotificationState (notificationType, pending = true) {
|
function setNotificationState (notificationType, pending = undefined) {
|
||||||
pendingNotifications[notificationType] = pending;
|
if (pending !== undefined) {
|
||||||
notificationState = NotificationState.UNNOTIFIED;
|
pendingNotifications[notificationType] = pending;
|
||||||
for (var key in pendingNotifications) {
|
notificationState = NotificationState.UNNOTIFIED;
|
||||||
if (pendingNotifications[key]) {
|
for (var key in pendingNotifications) {
|
||||||
notificationState = NotificationState.NOTIFIED;
|
if (pendingNotifications[key]) {
|
||||||
break;
|
notificationState = NotificationState.NOTIFIED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
||||||
|
@ -568,7 +570,42 @@ function updateLabels(serverState) {
|
||||||
labels.people.icon = pendingNotifications[HifiNotificationType.PEOPLE] ? menuNotificationIcon : null;
|
labels.people.icon = pendingNotifications[HifiNotificationType.PEOPLE] ? menuNotificationIcon : null;
|
||||||
labels.wallet.icon = pendingNotifications[HifiNotificationType.WALLET] ? menuNotificationIcon : null;
|
labels.wallet.icon = pendingNotifications[HifiNotificationType.WALLET] ? menuNotificationIcon : null;
|
||||||
labels.marketplace.icon = pendingNotifications[HifiNotificationType.MARKETPLACE] ? menuNotificationIcon : null;
|
labels.marketplace.icon = pendingNotifications[HifiNotificationType.MARKETPLACE] ? menuNotificationIcon : null;
|
||||||
|
var onlineUsers = trayNotifications.getOnlineUsers();
|
||||||
|
delete labels.people.submenu;
|
||||||
|
if (onlineUsers) {
|
||||||
|
for (var name in onlineUsers) {
|
||||||
|
if(labels.people.submenu == undefined) {
|
||||||
|
labels.people.submenu = [];
|
||||||
|
}
|
||||||
|
labels.people.submenu.push({
|
||||||
|
label: name,
|
||||||
|
enabled: (onlineUsers[name].location != undefined),
|
||||||
|
click: function (item) {
|
||||||
|
setNotificationState(HifiNotificationType.PEOPLE, false);
|
||||||
|
if(onlineUsers[item.label] && onlineUsers[item.label].location) {
|
||||||
|
StartInterface("hifi://" + onlineUsers[item.label].location.root.name + onlineUsers[item.label].location.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var currentStories = trayNotifications.getCurrentStories();
|
||||||
|
delete labels.goto.submenu;
|
||||||
|
if (currentStories) {
|
||||||
|
for (var location in currentStories) {
|
||||||
|
if(labels.goto.submenu == undefined) {
|
||||||
|
labels.goto.submenu = [];
|
||||||
|
}
|
||||||
|
labels.goto.submenu.push({
|
||||||
|
label: "event in " + location,
|
||||||
|
location: location,
|
||||||
|
click: function (item) {
|
||||||
|
setNotificationState(HifiNotificationType.GOTO, false);
|
||||||
|
StartInterface("hifi://" + item.location + currentStories[item.location].path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTrayMenu(serverState) {
|
function updateTrayMenu(serverState) {
|
||||||
|
|
|
@ -73,11 +73,17 @@ HifiNotification.prototype = {
|
||||||
text = this.data + " of your connections are online."
|
text = this.data + " of your connections are online."
|
||||||
}
|
}
|
||||||
message = "Click to open PEOPLE.";
|
message = "Click to open PEOPLE.";
|
||||||
url="hifiapp:PEOPLE"
|
url="hifiapp:PEOPLE";
|
||||||
} else {
|
} else {
|
||||||
text = this.data.username + " is available in " + this.data.location.root.name + ".";
|
if (this.data.location) {
|
||||||
message = "Click to join them.";
|
text = this.data.username + " is available in " + this.data.location.root.name + ".";
|
||||||
url="hifi://" + this.data.location.root.name + this.data.location.path;
|
message = "Click to join them.";
|
||||||
|
url="hifi://" + this.data.location.root.name + this.data.location.path;
|
||||||
|
} else {
|
||||||
|
text = this.data.username + " is online.";
|
||||||
|
message = "Click to open PEOPLE.";
|
||||||
|
url="hifiapp:PEOPLE";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -136,7 +142,8 @@ HifiNotification.prototype = {
|
||||||
function HifiNotifications(config, menuNotificationCallback) {
|
function HifiNotifications(config, menuNotificationCallback) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.menuNotificationCallback = menuNotificationCallback;
|
this.menuNotificationCallback = menuNotificationCallback;
|
||||||
this.onlineUsers = new Set([]);
|
this.onlineUsers = {};
|
||||||
|
this.currentStories = {};
|
||||||
this.storiesSince = new Date(this.config.get("storiesNotifySince", "1970-01-01T00:00:00.000Z"));
|
this.storiesSince = new Date(this.config.get("storiesNotifySince", "1970-01-01T00:00:00.000Z"));
|
||||||
this.peopleSince = new Date(this.config.get("peopleNotifySince", "1970-01-01T00:00:00.000Z"));
|
this.peopleSince = new Date(this.config.get("peopleNotifySince", "1970-01-01T00:00:00.000Z"));
|
||||||
this.walletSince = new Date(this.config.get("walletNotifySince", "1970-01-01T00:00:00.000Z"));
|
this.walletSince = new Date(this.config.get("walletNotifySince", "1970-01-01T00:00:00.000Z"));
|
||||||
|
@ -213,6 +220,12 @@ HifiNotifications.prototype = {
|
||||||
clearInterval(this.marketplacePollTimer);
|
clearInterval(this.marketplacePollTimer);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getOnlineUsers: function () {
|
||||||
|
return this.onlineUsers;
|
||||||
|
},
|
||||||
|
getCurrentStories: function () {
|
||||||
|
return this.currentStories;
|
||||||
|
},
|
||||||
_showNotification: function () {
|
_showNotification: function () {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
|
@ -225,7 +238,7 @@ HifiNotifications.prototype = {
|
||||||
// previous notification immediately when a
|
// previous notification immediately when a
|
||||||
// new one is submitted
|
// new one is submitted
|
||||||
_this.pendingNotifications.shift();
|
_this.pendingNotifications.shift();
|
||||||
if(_this.pendingNotifications.length > 0) {
|
if (_this.pendingNotifications.length > 0) {
|
||||||
_this._showNotification();
|
_this._showNotification();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -289,7 +302,6 @@ HifiNotifications.prototype = {
|
||||||
finished(false);
|
finished(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(content);
|
|
||||||
if (!content.total_entries) {
|
if (!content.total_entries) {
|
||||||
finished(true, token);
|
finished(true, token);
|
||||||
return;
|
return;
|
||||||
|
@ -313,7 +325,6 @@ HifiNotifications.prototype = {
|
||||||
notifyData = content.data.updates;
|
notifyData = content.data.updates;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyData.forEach(function (notifyDataEntry) {
|
notifyData.forEach(function (notifyDataEntry) {
|
||||||
_this._addNotification(new HifiNotification(notifyType, notifyDataEntry));
|
_this._addNotification(new HifiNotification(notifyType, notifyDataEntry));
|
||||||
});
|
});
|
||||||
|
@ -346,7 +357,7 @@ HifiNotifications.prototype = {
|
||||||
'include_actions=announcement',
|
'include_actions=announcement',
|
||||||
'restriction=open,hifi',
|
'restriction=open,hifi',
|
||||||
'require_online=true',
|
'require_online=true',
|
||||||
'per_page=1'
|
'per_page=' + MAX_NOTIFICATION_ITEMS
|
||||||
];
|
];
|
||||||
var url = METAVERSE_SERVER_URL + STORIES_URL + '?' + options.join('&');
|
var url = METAVERSE_SERVER_URL + STORIES_URL + '?' + options.join('&');
|
||||||
// call a second time to determine if there are no more stories and we should
|
// call a second time to determine if there are no more stories and we should
|
||||||
|
@ -357,7 +368,34 @@ HifiNotifications.prototype = {
|
||||||
'bearer': token
|
'bearer': token
|
||||||
}
|
}
|
||||||
}, function (error, data) {
|
}, function (error, data) {
|
||||||
_this._pollToDisableHighlight(NotificationType.GOTO, error, data);
|
if (error || !data.body) {
|
||||||
|
console.log("Error: unable to get " + url);
|
||||||
|
finished(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var content = JSON.parse(data.body);
|
||||||
|
if (!content || content.status != 'success') {
|
||||||
|
console.log("Error: unable to get " + url);
|
||||||
|
finished(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!content.total_entries) {
|
||||||
|
finished(true, token);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!content.total_entries) {
|
||||||
|
_this.menuNotificationCallback(NotificationType.GOTO, false);
|
||||||
|
}
|
||||||
|
_this.currentStories = {};
|
||||||
|
content.user_stories.forEach(function (story) {
|
||||||
|
// only show a single instance of each story location
|
||||||
|
// in the menu. This may cause issues with domains
|
||||||
|
// where the story locations are significantly different
|
||||||
|
// for each story.
|
||||||
|
_this.currentStories[story.place_name] = story;
|
||||||
|
});
|
||||||
|
_this.menuNotificationCallback(NotificationType.GOTO);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -400,20 +438,19 @@ HifiNotifications.prototype = {
|
||||||
console.log("Error: unable to get " + url);
|
console.log("Error: unable to get " + url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
console.log(content);
|
|
||||||
if (!content.total_entries) {
|
if (!content.total_entries) {
|
||||||
_this.menuNotificationCallback(NotificationType.PEOPLE, false);
|
_this.menuNotificationCallback(NotificationType.PEOPLE, false);
|
||||||
_this.onlineUsers = new Set([]);
|
_this.onlineUsers = {};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentUsers = new Set([]);
|
var currentUsers = {};
|
||||||
var newUsers = new Set([]);
|
var newUsers = new Set([]);
|
||||||
content.data.users.forEach(function (user) {
|
content.data.users.forEach(function (user) {
|
||||||
currentUsers.add(user.username);
|
currentUsers[user.username] = user;
|
||||||
if (!_this.onlineUsers.has(user.username)) {
|
if (!(user.username in _this.onlineUsers)) {
|
||||||
newUsers.add(user);
|
newUsers.add(user);
|
||||||
_this.onlineUsers.add(user.username);
|
_this.onlineUsers[user.username] = user;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_this.onlineUsers = currentUsers;
|
_this.onlineUsers = currentUsers;
|
||||||
|
|
Loading…
Reference in a new issue