mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 17:56:43 +02:00
Tray Notifier code review fixes
This commit is contained in:
parent
6f4c376d9f
commit
16dba169c5
4 changed files with 74 additions and 83 deletions
|
@ -3431,7 +3431,7 @@ void Application::handleSandboxStatus(QNetworkReply* reply) {
|
||||||
if (url.scheme() == URL_SCHEME_HIFIAPP) {
|
if (url.scheme() == URL_SCHEME_HIFIAPP) {
|
||||||
Setting::Handle<QVariant>("startUpApp").set(url.path());
|
Setting::Handle<QVariant>("startUpApp").set(url.path());
|
||||||
} else {
|
} else {
|
||||||
addressLookupString = arguments().value(urlIndex + 1);
|
addressLookupString = url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -401,7 +401,7 @@ bool QmlCommerce::openApp(const QString& itemHref) {
|
||||||
// Read from the file to know what .html or .qml document to open
|
// Read from the file to know what .html or .qml document to open
|
||||||
QFile appFile(_appsPath + "/" + appHref.fileName());
|
QFile appFile(_appsPath + "/" + appHref.fileName());
|
||||||
if (!appFile.open(QIODevice::ReadOnly)) {
|
if (!appFile.open(QIODevice::ReadOnly)) {
|
||||||
qCDebug(commerce) << "Couldn't open local .app.json file:" << _appsPath << "/" << appHref.fileName();
|
qCDebug(commerce) << "Couldn't open local .app.json file:" << appFile;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QJsonDocument appFileJsonDocument = QJsonDocument::fromJson(appFile.readAll());
|
QJsonDocument appFileJsonDocument = QJsonDocument::fromJson(appFile.readAll());
|
||||||
|
|
|
@ -155,7 +155,7 @@ function shutdownCallback(idx) {
|
||||||
logWindow.close();
|
logWindow.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isServerInstalled()) {
|
if (isServerInstalled()) {
|
||||||
if (homeServer) {
|
if (homeServer) {
|
||||||
log.debug("Stoping home server");
|
log.debug("Stoping home server");
|
||||||
homeServer.stop();
|
homeServer.stop();
|
||||||
|
@ -396,14 +396,14 @@ var labels = {
|
||||||
label: 'Show Notifications',
|
label: 'Show Notifications',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: true,
|
checked: true,
|
||||||
click: function() {
|
click: function () {
|
||||||
trayNotifications.enable(!trayNotifications.enabled(), notificationCallback);
|
trayNotifications.enable(!trayNotifications.enabled(), notificationCallback);
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
goto: {
|
goto: {
|
||||||
label: 'GoTo',
|
label: 'GoTo',
|
||||||
click: function() {
|
click: function () {
|
||||||
StartInterface("hifiapp:GOTO");
|
StartInterface("hifiapp:GOTO");
|
||||||
pendingNotifications[HifiNotificationType.GOTO] = false;
|
pendingNotifications[HifiNotificationType.GOTO] = false;
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
||||||
|
@ -411,7 +411,7 @@ var labels = {
|
||||||
},
|
},
|
||||||
people: {
|
people: {
|
||||||
label: 'People',
|
label: 'People',
|
||||||
click: function() {
|
click: function () {
|
||||||
StartInterface("hifiapp:PEOPLE");
|
StartInterface("hifiapp:PEOPLE");
|
||||||
pendingNotifications[HifiNotificationType.PEOPLE] = false;
|
pendingNotifications[HifiNotificationType.PEOPLE] = false;
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
||||||
|
@ -419,7 +419,7 @@ var labels = {
|
||||||
},
|
},
|
||||||
wallet: {
|
wallet: {
|
||||||
label: 'Wallet',
|
label: 'Wallet',
|
||||||
click: function() {
|
click: function () {
|
||||||
StartInterface("hifiapp:WALLET");
|
StartInterface("hifiapp:WALLET");
|
||||||
pendingNotifications[HifiNotificationType.WALLET] = false;
|
pendingNotifications[HifiNotificationType.WALLET] = false;
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
||||||
|
@ -427,7 +427,7 @@ var labels = {
|
||||||
},
|
},
|
||||||
marketplace: {
|
marketplace: {
|
||||||
label: 'Market',
|
label: 'Market',
|
||||||
click: function() {
|
click: function () {
|
||||||
StartInterface("hifiapp:MARKET");
|
StartInterface("hifiapp:MARKET");
|
||||||
pendingNotifications[HifiNotificationType.MARKETPLACE] = false;
|
pendingNotifications[HifiNotificationType.MARKETPLACE] = false;
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
||||||
|
@ -497,16 +497,16 @@ function buildMenuArray(serverState) {
|
||||||
if (isShuttingDown) {
|
if (isShuttingDown) {
|
||||||
menuArray.push(labels.shuttingDown);
|
menuArray.push(labels.shuttingDown);
|
||||||
} else {
|
} else {
|
||||||
if(isServerInstalled()) {
|
if (isServerInstalled()) {
|
||||||
menuArray.push(labels.serverState);
|
menuArray.push(labels.serverState);
|
||||||
menuArray.push(labels.version);
|
menuArray.push(labels.version);
|
||||||
menuArray.push(separator);
|
menuArray.push(separator);
|
||||||
}
|
}
|
||||||
if(isServerInstalled() && isInterfaceInstalled()) {
|
if (isServerInstalled() && isInterfaceInstalled()) {
|
||||||
menuArray.push(labels.goHome);
|
menuArray.push(labels.goHome);
|
||||||
menuArray.push(separator);
|
menuArray.push(separator);
|
||||||
}
|
}
|
||||||
if(isServerInstalled()) {
|
if (isServerInstalled()) {
|
||||||
menuArray.push(labels.restart);
|
menuArray.push(labels.restart);
|
||||||
menuArray.push(labels.stopServer);
|
menuArray.push(labels.stopServer);
|
||||||
menuArray.push(labels.settings);
|
menuArray.push(labels.settings);
|
||||||
|
@ -515,7 +515,7 @@ function buildMenuArray(serverState) {
|
||||||
}
|
}
|
||||||
menuArray.push(labels.share);
|
menuArray.push(labels.share);
|
||||||
menuArray.push(separator);
|
menuArray.push(separator);
|
||||||
if(isInterfaceInstalled()) {
|
if (isInterfaceInstalled()) {
|
||||||
menuArray.push(labels.goto);
|
menuArray.push(labels.goto);
|
||||||
menuArray.push(labels.people);
|
menuArray.push(labels.people);
|
||||||
menuArray.push(labels.wallet);
|
menuArray.push(labels.wallet);
|
||||||
|
|
|
@ -9,10 +9,10 @@ const GetBuildInfo = hfApp.getBuildInfo;
|
||||||
const buildInfo = GetBuildInfo();
|
const buildInfo = GetBuildInfo();
|
||||||
|
|
||||||
const notificationIcon = path.join(__dirname, '../../resources/console-notification.png');
|
const notificationIcon = path.join(__dirname, '../../resources/console-notification.png');
|
||||||
const STORIES_NOTIFICATION_POLL_TIME_MS = 15 * 1000;
|
const STORIES_NOTIFICATION_POLL_TIME_MS = 15 * 1000; // 120 * 1000;
|
||||||
const PEOPLE_NOTIFICATION_POLL_TIME_MS = 15 * 1000;
|
const PEOPLE_NOTIFICATION_POLL_TIME_MS = 15 * 1000; // 120 * 1000;
|
||||||
const WALLET_NOTIFICATION_POLL_TIME_MS = 15 * 1000;
|
const WALLET_NOTIFICATION_POLL_TIME_MS = 15 * 1000; // 600 * 1000;
|
||||||
const MARKETPLACE_NOTIFICATION_POLL_TIME_MS = 15 * 1000;
|
const MARKETPLACE_NOTIFICATION_POLL_TIME_MS = 15 * 1000; // 600 * 1000;
|
||||||
|
|
||||||
const METAVERSE_SERVER_URL= process.env.HIFI_METAVERSE_URL ? process.env.HIFI_METAVERSE_URL : 'https://metaverse.highfidelity.com'
|
const METAVERSE_SERVER_URL= process.env.HIFI_METAVERSE_URL ? process.env.HIFI_METAVERSE_URL : 'https://metaverse.highfidelity.com'
|
||||||
const STORIES_URL= '/api/v1/user_stories';
|
const STORIES_URL= '/api/v1/user_stories';
|
||||||
|
@ -39,24 +39,22 @@ function HifiNotification(notificationType, notificationData, menuNotificationCa
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiNotification.prototype = {
|
HifiNotification.prototype = {
|
||||||
show: function() {
|
show: function () {
|
||||||
var text = "";
|
var text = "";
|
||||||
var message = "";
|
var message = "";
|
||||||
var url = null;
|
var url = null;
|
||||||
var app = null;
|
var app = null;
|
||||||
switch(this.type) {
|
switch (this.type) {
|
||||||
case NotificationType.GOTO:
|
case NotificationType.GOTO:
|
||||||
if(typeof(this.data) == "number") {
|
if (typeof(this.data) == "number") {
|
||||||
if (this.data == 1) {
|
if (this.data == 1) {
|
||||||
text = "You have " + this.data + " event invitation pending."
|
text = "You have " + this.data + " event invitation pending."
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
text = "You have " + this.data + " event invitations pending."
|
text = "You have " + this.data + " event invitations pending."
|
||||||
}
|
}
|
||||||
message = "Click to open GOTO.";
|
message = "Click to open GOTO.";
|
||||||
url="hifiapp:GOTO"
|
url="hifiapp:GOTO"
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
text = this.data.username + " " + this.data.action_string + " in " + this.data.place_name + ".";
|
text = this.data.username + " " + this.data.action_string + " in " + this.data.place_name + ".";
|
||||||
message = "Click to go to " + this.data.place_name + ".";
|
message = "Click to go to " + this.data.place_name + ".";
|
||||||
url = "hifi://" + this.data.place_name + this.data.path;
|
url = "hifi://" + this.data.place_name + this.data.path;
|
||||||
|
@ -64,17 +62,15 @@ HifiNotification.prototype = {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotificationType.PEOPLE:
|
case NotificationType.PEOPLE:
|
||||||
if(typeof(this.data) == "number") {
|
if (typeof(this.data) == "number") {
|
||||||
if (this.data == 1) {
|
if (this.data == 1) {
|
||||||
text = this.data + " of your connections is online."
|
text = this.data + " of your connections is online."
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
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 + ".";
|
text = this.data.username + " is available in " + this.data.location.root.name + ".";
|
||||||
message = "Click to join them.";
|
message = "Click to join them.";
|
||||||
url="hifi://" + this.data.location.root.name + this.data.location.path;
|
url="hifi://" + this.data.location.root.name + this.data.location.path;
|
||||||
|
@ -82,11 +78,10 @@ HifiNotification.prototype = {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotificationType.WALLET:
|
case NotificationType.WALLET:
|
||||||
if(typeof(this.data) == "number") {
|
if (typeof(this.data) == "number") {
|
||||||
if (this.data == 1) {
|
if (this.data == 1) {
|
||||||
text = "You have " + this.data + " unread Wallet transaction.";
|
text = "You have " + this.data + " unread Wallet transaction.";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
text = "You have " + this.data + " unread Wallet transactions.";
|
text = "You have " + this.data + " unread Wallet transactions.";
|
||||||
}
|
}
|
||||||
message = "Click to open WALLET."
|
message = "Click to open WALLET."
|
||||||
|
@ -99,15 +94,13 @@ HifiNotification.prototype = {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotificationType.MARKETPLACE:
|
case NotificationType.MARKETPLACE:
|
||||||
if(typeof(this.data) == "number") {
|
if (typeof(this.data) == "number") {
|
||||||
if (this.data == 1) {
|
if (this.data == 1) {
|
||||||
text = this.data + " of your purchased items has an update available.";
|
text = this.data + " of your purchased items has an update available.";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
text = this.data + " of your purchased items have updates available.";
|
text = this.data + " of your purchased items have updates available.";
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
text = "Update available for " + this.data.base_item_title + ".";
|
text = "Update available for " + this.data.base_item_title + ".";
|
||||||
}
|
}
|
||||||
message = "Click to open MARKET.";
|
message = "Click to open MARKET.";
|
||||||
|
@ -138,64 +131,63 @@ function HifiNotifications(config, menuNotificationCallback) {
|
||||||
this.enable(this.enabled());
|
this.enable(this.enabled());
|
||||||
|
|
||||||
var _menuNotificationCallback = menuNotificationCallback;
|
var _menuNotificationCallback = menuNotificationCallback;
|
||||||
notifier.on('click', function(notifierObject, options) {
|
notifier.on('click', function (notifierObject, options) {
|
||||||
StartInterface(options.url);
|
StartInterface(options.url);
|
||||||
_menuNotificationCallback(options.notificationType, false);
|
_menuNotificationCallback(options.notificationType, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiNotifications.prototype = {
|
HifiNotifications.prototype = {
|
||||||
enable: function(enabled) {
|
enable: function (enabled) {
|
||||||
this.config.set("enableTrayNotifications", enabled);
|
this.config.set("enableTrayNotifications", enabled);
|
||||||
if(enabled) {
|
if (enabled) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.storiesPollTimer = setInterval(function() {
|
this.storiesPollTimer = setInterval(function () {
|
||||||
var _since = _this.storiesSince;
|
var _since = _this.storiesSince;
|
||||||
_this.storiesSince = new Date();
|
_this.storiesSince = new Date();
|
||||||
_this.pollForStories(_since);
|
_this.pollForStories(_since);
|
||||||
},
|
},
|
||||||
STORIES_NOTIFICATION_POLL_TIME_MS);
|
STORIES_NOTIFICATION_POLL_TIME_MS);
|
||||||
|
|
||||||
this.peoplePollTimer = setInterval(function() {
|
this.peoplePollTimer = setInterval(function () {
|
||||||
var _since = _this.peopleSince;
|
var _since = _this.peopleSince;
|
||||||
_this.peopleSince = new Date();
|
_this.peopleSince = new Date();
|
||||||
_this.pollForConnections(_since);
|
_this.pollForConnections(_since);
|
||||||
},
|
},
|
||||||
PEOPLE_NOTIFICATION_POLL_TIME_MS);
|
PEOPLE_NOTIFICATION_POLL_TIME_MS);
|
||||||
|
|
||||||
this.walletPollTimer = setInterval(function() {
|
this.walletPollTimer = setInterval(function () {
|
||||||
var _since = _this.walletSince;
|
var _since = _this.walletSince;
|
||||||
_this.walletSince = new Date();
|
_this.walletSince = new Date();
|
||||||
_this.pollForEconomicActivity(_since);
|
_this.pollForEconomicActivity(_since);
|
||||||
},
|
},
|
||||||
WALLET_NOTIFICATION_POLL_TIME_MS);
|
WALLET_NOTIFICATION_POLL_TIME_MS);
|
||||||
|
|
||||||
this.marketplacePollTimer = setInterval(function() {
|
this.marketplacePollTimer = setInterval(function () {
|
||||||
var _since = _this.marketplaceSince;
|
var _since = _this.marketplaceSince;
|
||||||
_this.marketplaceSince = new Date();
|
_this.marketplaceSince = new Date();
|
||||||
_this.pollForMarketplaceUpdates(_since);
|
_this.pollForMarketplaceUpdates(_since);
|
||||||
},
|
},
|
||||||
MARKETPLACE_NOTIFICATION_POLL_TIME_MS);
|
MARKETPLACE_NOTIFICATION_POLL_TIME_MS);
|
||||||
}
|
} else {
|
||||||
else {
|
if (this.storiesPollTimer) {
|
||||||
if(this.storiesPollTimer) {
|
|
||||||
clearInterval(this.storiesPollTimer);
|
clearInterval(this.storiesPollTimer);
|
||||||
}
|
}
|
||||||
if(this.peoplePollTimer) {
|
if (this.peoplePollTimer) {
|
||||||
clearInterval(this.peoplePollTimer);
|
clearInterval(this.peoplePollTimer);
|
||||||
}
|
}
|
||||||
if(this.walletPollTimer) {
|
if (this.walletPollTimer) {
|
||||||
clearInterval(this.walletPollTimer);
|
clearInterval(this.walletPollTimer);
|
||||||
}
|
}
|
||||||
if(this.marketplacePollTimer) {
|
if (this.marketplacePollTimer) {
|
||||||
clearInterval(this.marketplacePollTimer);
|
clearInterval(this.marketplacePollTimer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enabled: function() {
|
enabled: function () {
|
||||||
return this.config.get("enableTrayNotifications", true);
|
return this.config.get("enableTrayNotifications", true);
|
||||||
},
|
},
|
||||||
stopPolling: function() {
|
stopPolling: function () {
|
||||||
this.config.set("storiesNotifySince", this.storiesSince.toISOString());
|
this.config.set("storiesNotifySince", this.storiesSince.toISOString());
|
||||||
this.config.set("peopleNotifySince", this.peopleSince.toISOString());
|
this.config.set("peopleNotifySince", this.peopleSince.toISOString());
|
||||||
this.config.set("walletNotifySince", this.walletSince.toISOString());
|
this.config.set("walletNotifySince", this.walletSince.toISOString());
|
||||||
|
@ -203,31 +195,31 @@ HifiNotifications.prototype = {
|
||||||
|
|
||||||
this.enable(false);
|
this.enable(false);
|
||||||
},
|
},
|
||||||
_pollToDisableHighlight: function(notifyType, error, data) {
|
_pollToDisableHighlight: function (notifyType, error, data) {
|
||||||
if (error || !data.body) {
|
if (error || !data.body) {
|
||||||
console.log("Error: unable to get " + url);
|
console.log("Error: unable to get " + url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var content = JSON.parse(data.body);
|
var content = JSON.parse(data.body);
|
||||||
if(!content || content.status != 'success') {
|
if (!content || content.status != 'success') {
|
||||||
console.log("Error: unable to get " + url);
|
console.log("Error: unable to get " + url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!content.total_entries) {
|
if (!content.total_entries) {
|
||||||
this.menuNotificationCallback(notifyType, false);
|
this.menuNotificationCallback(notifyType, false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_pollCommon: function(notifyType, url, since, finished) {
|
_pollCommon: function (notifyType, url, since, finished) {
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
IsInterfaceRunning(function(running) {
|
IsInterfaceRunning(function (running) {
|
||||||
if(running) {
|
if (running) {
|
||||||
finished(false);
|
finished(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var acctInfo = new AccountInfo();
|
var acctInfo = new AccountInfo();
|
||||||
var token = acctInfo.accessToken(METAVERSE_SERVER_URL);
|
var token = acctInfo.accessToken(METAVERSE_SERVER_URL);
|
||||||
if(!token) {
|
if (!token) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
request.get({
|
request.get({
|
||||||
|
@ -244,24 +236,23 @@ HifiNotifications.prototype = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var content = JSON.parse(data.body);
|
var content = JSON.parse(data.body);
|
||||||
if(!content || content.status != 'success') {
|
if (!content || content.status != 'success') {
|
||||||
console.log("Error: unable to get " + url);
|
console.log("Error: unable to get " + url);
|
||||||
finished(false);
|
finished(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(content);
|
console.log(content);
|
||||||
if(!content.total_entries) {
|
if (!content.total_entries) {
|
||||||
finished(true, token);
|
finished(true, token);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_this.menuNotificationCallback(notifyType, true);
|
_this.menuNotificationCallback(notifyType, true);
|
||||||
if(content.total_entries >= maxNotificationItemCount) {
|
if (content.total_entries >= maxNotificationItemCount) {
|
||||||
var notification = new HifiNotification(notifyType, content.total_entries);
|
var notification = new HifiNotification(notifyType, content.total_entries);
|
||||||
notification.show();
|
notification.show();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var notifyData = []
|
var notifyData = []
|
||||||
switch(notifyType) {
|
switch (notifyType) {
|
||||||
case NotificationType.GOTO:
|
case NotificationType.GOTO:
|
||||||
notifyData = content.user_stories;
|
notifyData = content.user_stories;
|
||||||
break;
|
break;
|
||||||
|
@ -276,7 +267,7 @@ HifiNotifications.prototype = {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyData.forEach(function(notifyDataEntry) {
|
notifyData.forEach(function (notifyDataEntry) {
|
||||||
var notification = new HifiNotification(notifyType, notifyDataEntry);
|
var notification = new HifiNotification(notifyType, notifyDataEntry);
|
||||||
notification.show();
|
notification.show();
|
||||||
});
|
});
|
||||||
|
@ -285,7 +276,7 @@ HifiNotifications.prototype = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pollForStories: function(since) {
|
pollForStories: function (since) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var actions = 'announcement';
|
var actions = 'announcement';
|
||||||
var options = [
|
var options = [
|
||||||
|
@ -303,7 +294,7 @@ HifiNotifications.prototype = {
|
||||||
url,
|
url,
|
||||||
since,
|
since,
|
||||||
function (success, token) {
|
function (success, token) {
|
||||||
if(success) {
|
if (success) {
|
||||||
var options = [
|
var options = [
|
||||||
'now=' + new Date().toISOString(),
|
'now=' + new Date().toISOString(),
|
||||||
'include_actions=announcement',
|
'include_actions=announcement',
|
||||||
|
@ -319,17 +310,17 @@ HifiNotifications.prototype = {
|
||||||
'auth': {
|
'auth': {
|
||||||
'bearer': token
|
'bearer': token
|
||||||
}
|
}
|
||||||
}, function(error, data) {
|
}, function (error, data) {
|
||||||
_this._pollToDisableHighlight(NotificationType.GOTO, error, data);
|
_this._pollToDisableHighlight(NotificationType.GOTO, error, data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pollForConnections: function(since) {
|
pollForConnections: function (since) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var _since = since;
|
var _since = since;
|
||||||
IsInterfaceRunning(function(running) {
|
IsInterfaceRunning(function (running) {
|
||||||
if(running) {
|
if (running) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var options = [
|
var options = [
|
||||||
|
@ -343,7 +334,7 @@ HifiNotifications.prototype = {
|
||||||
console.log(url);
|
console.log(url);
|
||||||
var acctInfo = new AccountInfo();
|
var acctInfo = new AccountInfo();
|
||||||
var token = acctInfo.accessToken(METAVERSE_SERVER_URL);
|
var token = acctInfo.accessToken(METAVERSE_SERVER_URL);
|
||||||
if(!token) {
|
if (!token) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
request.get({
|
request.get({
|
||||||
|
@ -359,12 +350,12 @@ HifiNotifications.prototype = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var content = JSON.parse(data.body);
|
var content = JSON.parse(data.body);
|
||||||
if(!content || content.status != 'success') {
|
if (!content || content.status != 'success') {
|
||||||
console.log("Error: unable to get " + url);
|
console.log("Error: unable to get " + url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
console.log(content);
|
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 = new Set([]);
|
||||||
return;
|
return;
|
||||||
|
@ -372,31 +363,31 @@ HifiNotifications.prototype = {
|
||||||
|
|
||||||
var currentUsers = new Set([]);
|
var currentUsers = new Set([]);
|
||||||
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.add(user.username);
|
||||||
if(!_this.onlineUsers.has(user.username)) {
|
if (!_this.onlineUsers.has(user.username)) {
|
||||||
newUsers.add(user);
|
newUsers.add(user);
|
||||||
_this.onlineUsers.add(user.username);
|
_this.onlineUsers.add(user.username);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_this.onlineUsers = currentUsers;
|
_this.onlineUsers = currentUsers;
|
||||||
if(newUsers.size) {
|
if (newUsers.size) {
|
||||||
_this.menuNotificationCallback(NotificationType.PEOPLE, true);
|
_this.menuNotificationCallback(NotificationType.PEOPLE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newUsers.size >= maxNotificationItemCount) {
|
if (newUsers.size >= maxNotificationItemCount) {
|
||||||
var notification = new HifiNotification(NotificationType.PEOPLE, newUsers.size);
|
var notification = new HifiNotification(NotificationType.PEOPLE, newUsers.size);
|
||||||
notification.show();
|
notification.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newUsers.forEach(function(user) {
|
newUsers.forEach(function (user) {
|
||||||
var notification = new HifiNotification(NotificationType.PEOPLE, user);
|
var notification = new HifiNotification(NotificationType.PEOPLE, user);
|
||||||
notification.show();
|
notification.show();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pollForEconomicActivity: function(since) {
|
pollForEconomicActivity: function (since) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var options = [
|
var options = [
|
||||||
'since=' + since.getTime() / 1000,
|
'since=' + since.getTime() / 1000,
|
||||||
|
@ -410,7 +401,7 @@ HifiNotifications.prototype = {
|
||||||
console.log(url);
|
console.log(url);
|
||||||
_this._pollCommon(NotificationType.WALLET, url, since, function () {});
|
_this._pollCommon(NotificationType.WALLET, url, since, function () {});
|
||||||
},
|
},
|
||||||
pollForMarketplaceUpdates: function(since) {
|
pollForMarketplaceUpdates: function (since) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var options = [
|
var options = [
|
||||||
'since=' + since.getTime() / 1000,
|
'since=' + since.getTime() / 1000,
|
||||||
|
@ -421,7 +412,7 @@ HifiNotifications.prototype = {
|
||||||
var url = METAVERSE_SERVER_URL + UPDATES_URL + '?' + options.join('&');
|
var url = METAVERSE_SERVER_URL + UPDATES_URL + '?' + options.join('&');
|
||||||
console.log(url);
|
console.log(url);
|
||||||
_this._pollCommon(NotificationType.MARKETPLACE, url, since, function (success, token) {
|
_this._pollCommon(NotificationType.MARKETPLACE, url, since, function (success, token) {
|
||||||
if(success) {
|
if (success) {
|
||||||
var options = [
|
var options = [
|
||||||
'page=1',
|
'page=1',
|
||||||
'per_page=1'
|
'per_page=1'
|
||||||
|
@ -432,7 +423,7 @@ HifiNotifications.prototype = {
|
||||||
'auth': {
|
'auth': {
|
||||||
'bearer': token
|
'bearer': token
|
||||||
}
|
}
|
||||||
}, function(error, data) {
|
}, function (error, data) {
|
||||||
_this._pollToDisableHighlight(NotificationType.MARKETPLACE, error, data);
|
_this._pollToDisableHighlight(NotificationType.MARKETPLACE, error, data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue