mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 17:59:33 +02:00
Checkpoint tray notifications
* Fix app launch * refactor notifications code * fixup wording
This commit is contained in:
parent
bda179697e
commit
6e051b7431
5 changed files with 277 additions and 185 deletions
|
@ -49,11 +49,11 @@ QmlCommerce::QmlCommerce() {
|
||||||
|
|
||||||
void QmlCommerce::openSystemApp(const QString& appPath) {
|
void QmlCommerce::openSystemApp(const QString& appPath) {
|
||||||
|
|
||||||
QUrl appUrl = PathUtils::qmlUrl(appPath);
|
|
||||||
|
|
||||||
auto tablet = dynamic_cast<TabletProxy*>(
|
auto tablet = dynamic_cast<TabletProxy*>(
|
||||||
DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system"));
|
DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
tablet->loadQMLSource(appUrl);
|
tablet->loadQMLSource(appPath);
|
||||||
|
|
||||||
|
DependencyManager::get<HMDScriptingInterface>()->openTablet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 319 B After Width: | Height: | Size: 319 B |
|
@ -426,7 +426,7 @@ var labels = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
marketplace: {
|
marketplace: {
|
||||||
label: 'Marketplace',
|
label: 'Market',
|
||||||
click: function() {
|
click: function() {
|
||||||
StartInterface("hifiapp:hifi/commerce/purchases/Purchases.qml");
|
StartInterface("hifiapp:hifi/commerce/purchases/Purchases.qml");
|
||||||
pendingNotifications[HifiNotificationType.MARKETPLACE] = false;
|
pendingNotifications[HifiNotificationType.MARKETPLACE] = false;
|
||||||
|
|
|
@ -36,7 +36,10 @@ function AccountInfo() {
|
||||||
AccountInfo.prototype = {
|
AccountInfo.prototype = {
|
||||||
|
|
||||||
accessToken: function(metaverseUrl) {
|
accessToken: function(metaverseUrl) {
|
||||||
|
if(this.data && this.data[metaverseUrl] && this.data[metaverseUrl]["accessToken"]) {
|
||||||
return this.data[metaverseUrl]["accessToken"]["token"];
|
return this.data[metaverseUrl]["accessToken"]["token"];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
_parseUInt32: function () {
|
_parseUInt32: function () {
|
||||||
if (!this.rawData || (this.rawData.length - this.parseOffset < 4)) {
|
if (!this.rawData || (this.rawData.length - this.parseOffset < 4)) {
|
||||||
|
|
|
@ -9,14 +9,18 @@ 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 NOTIFICATION_POLL_TIME_MS = 15 * 1000;
|
const STORIES_NOTIFICATION_POLL_TIME_MS = 15 * 1000;
|
||||||
|
const PEOPLE_NOTIFICATION_POLL_TIME_MS = 15 * 1000;
|
||||||
|
const WALLET_NOTIFICATION_POLL_TIME_MS = 15 * 1000;
|
||||||
|
const MARKETPLACE_NOTIFICATION_POLL_TIME_MS = 15 * 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';
|
||||||
const USERS_URL= '/api/v1/users';
|
const USERS_URL= '/api/v1/users';
|
||||||
const ECONOMIC_ACTIVITY_URL= '/api/v1/commerce/history';
|
const ECONOMIC_ACTIVITY_URL= '/api/v1/commerce/history';
|
||||||
const UPDATES_URL= '/api/v1/commerce/available_updates';
|
const UPDATES_URL= '/api/v1/commerce/available_updates';
|
||||||
const MAX_NOTIFICATION_ITEMS=30
|
const MAX_NOTIFICATION_ITEMS=30
|
||||||
const STARTUP_MAX_NOTIFICATION_ITEMS=5
|
const STARTUP_MAX_NOTIFICATION_ITEMS=1
|
||||||
|
|
||||||
|
|
||||||
const StartInterface=hfApp.startInterface;
|
const StartInterface=hfApp.startInterface;
|
||||||
|
@ -43,61 +47,70 @@ HifiNotification.prototype = {
|
||||||
switch(this.type) {
|
switch(this.type) {
|
||||||
case NotificationType.GOTO:
|
case NotificationType.GOTO:
|
||||||
if(typeof(this.data) == "number") {
|
if(typeof(this.data) == "number") {
|
||||||
text = this.data + " events are happening."
|
if (this.data == 1) {
|
||||||
|
text = "You have " + this.data + " event invitation pending."
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
text = "You have " + this.data + " event invitations pending."
|
||||||
|
}
|
||||||
message = "Click to open GOTO.";
|
message = "Click to open GOTO.";
|
||||||
url="hifiapp:hifi/tablet/TabletAddressDialog.qml"
|
url="hifiapp:hifi/tablet/TabletAddressDialog.qml"
|
||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotificationType.PEOPLE:
|
case NotificationType.PEOPLE:
|
||||||
if(typeof(this.data) == "number") {
|
if(typeof(this.data) == "number") {
|
||||||
|
if (this.data == 1) {
|
||||||
text = this.data + " of your connections is online."
|
text = this.data + " of your connections is online."
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
text = this.data + " of your connections are online."
|
||||||
|
}
|
||||||
message = "Click to open PEOPLE.";
|
message = "Click to open PEOPLE.";
|
||||||
url="hifiapp:hifi/Pal.qml"
|
url="hifiapp:hifi/Pal.qml"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log(this.data);
|
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;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotificationType.WALLET:
|
case NotificationType.WALLET:
|
||||||
if(typeof(this.data) == "number") {
|
if(typeof(this.data) == "number") {
|
||||||
text = "You have " + this.data + " unread Wallet notifications!";
|
if (this.data == 1) {
|
||||||
|
text = "You have " + this.data + " unread Wallet transaction.";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
text = "You have " + this.data + " unread Wallet transactions.";
|
||||||
|
}
|
||||||
message = "Click to open WALLET."
|
message = "Click to open WALLET."
|
||||||
url = "hifiapp:hifi/commerce/wallet/Wallet.qml";
|
url = "hifiapp:hifi/commerce/wallet/Wallet.qml";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
text = "Economic activity.";
|
|
||||||
var memo = "";
|
|
||||||
if(this.data.sent_certs <= 0 && this.data.received_certs <= 0) {
|
|
||||||
if(this.data.received_money > 0) {
|
|
||||||
text = this.data.sender_name + " sent you " + this.data.received_money + " HFC!";
|
|
||||||
memo = "memo: \"" + this.data.message + "\" ";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
text = this.data.message.replace(/<\/?[^>]+(>|$)/g, "");
|
text = this.data.message.replace(/<\/?[^>]+(>|$)/g, "");
|
||||||
}
|
message = "Click to open WALLET.";
|
||||||
message = memo + "Click to open WALLET.";
|
|
||||||
url = "hifiapp:hifi/commerce/wallet/Wallet.qml";
|
url = "hifiapp:hifi/commerce/wallet/Wallet.qml";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotificationType.MARKETPLACE:
|
case NotificationType.MARKETPLACE:
|
||||||
if(typeof(this.data) == "number") {
|
if(typeof(this.data) == "number") {
|
||||||
text = this.data + " of your purchased items have updates available!";
|
if (this.data == 1) {
|
||||||
|
text = this.data + " of your purchased items has an update available.";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
text = "There's an update available for your version of " + this.data.base_item_title + "!";
|
text = this.data + " of your purchased items have updates available.";
|
||||||
}
|
}
|
||||||
message = "Click to open MARKETPLACE.";
|
}
|
||||||
|
else {
|
||||||
|
text = "Update available for " + this.data.base_item_title + ".";
|
||||||
|
}
|
||||||
|
message = "Click to open MARKET.";
|
||||||
url = "hifiapp:hifi/commerce/purchases/Purchases.qml";
|
url = "hifiapp:hifi/commerce/purchases/Purchases.qml";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -113,11 +126,15 @@ HifiNotification.prototype = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function HifiNotifications(config, callback) {
|
function HifiNotifications(config, menuNotificationCallback) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.callback = callback;
|
this.menuNotificationCallback = menuNotificationCallback;
|
||||||
this.onlineUsers = new Set([]);
|
this.onlineUsers = new Set([]);
|
||||||
this.since = new Date(this.config.get("notifySince", "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.walletSince = new Date(this.config.get("walletNotifySince", "1970-01-01T00:00:00.000Z"));
|
||||||
|
this.marketplaceSince = new Date(this.config.get("marketplaceNotifySince", "1970-01-01T00:00:00.000Z"));
|
||||||
|
|
||||||
this.enable(this.enabled());
|
this.enable(this.enabled());
|
||||||
notifier.on('click', function(notifierObject, options) {
|
notifier.on('click', function(notifierObject, options) {
|
||||||
StartInterface(options.url);
|
StartInterface(options.url);
|
||||||
|
@ -129,35 +146,59 @@ HifiNotifications.prototype = {
|
||||||
this.config.set("enableTrayNotifications", enabled);
|
this.config.set("enableTrayNotifications", enabled);
|
||||||
if(enabled) {
|
if(enabled) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.pollTimer = setInterval(function() {
|
this.storiesPollTimer = setInterval(function() {
|
||||||
var acctInfo = new AccountInfo();
|
var _since = _this.storiesSince;
|
||||||
var token = acctInfo.accessToken(METAVERSE_SERVER_URL);
|
_this.storiesSince = new Date();
|
||||||
var _since = _this.since;
|
_this.pollForStories(_since);
|
||||||
_this.since = new Date();
|
|
||||||
IsInterfaceRunning(function(running) {
|
|
||||||
if(running) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_this.pollForStories(_since, token);
|
|
||||||
_this.pollForConnections(_since, token);
|
|
||||||
_this.pollForEconomicActivity(_since, token);
|
|
||||||
_this.pollForMarketplaceUpdates(_since, token);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
NOTIFICATION_POLL_TIME_MS);
|
STORIES_NOTIFICATION_POLL_TIME_MS);
|
||||||
|
|
||||||
|
this.peoplePollTimer = setInterval(function() {
|
||||||
|
var _since = _this.peopleSince;
|
||||||
|
_this.peopleSince = new Date();
|
||||||
|
_this.pollForConnections(_since);
|
||||||
|
},
|
||||||
|
PEOPLE_NOTIFICATION_POLL_TIME_MS);
|
||||||
|
|
||||||
|
this.walletPollTimer = setInterval(function() {
|
||||||
|
var _since = _this.walletSince;
|
||||||
|
_this.walletSince = new Date();
|
||||||
|
_this.pollForEconomicActivity(_since);
|
||||||
|
},
|
||||||
|
WALLET_NOTIFICATION_POLL_TIME_MS);
|
||||||
|
|
||||||
|
this.marketplacePollTimer = setInterval(function() {
|
||||||
|
var _since = _this.marketplaceSince;
|
||||||
|
_this.marketplaceSince = new Date();
|
||||||
|
_this.pollForMarketplaceUpdates(_since);
|
||||||
|
},
|
||||||
|
MARKETPLACE_NOTIFICATION_POLL_TIME_MS);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(this.storiesTimer) {
|
||||||
|
clearInterval(this.storiesTimer);
|
||||||
|
}
|
||||||
|
if(this.peoplePollTimer) {
|
||||||
|
clearInterval(this.peoplePollTimer);
|
||||||
|
}
|
||||||
|
if(this.walletPollTimer) {
|
||||||
|
clearInterval(this.walletPollTimer);
|
||||||
|
}
|
||||||
|
if(this.marketplacePollTimer) {
|
||||||
|
clearInterval(this.marketplacePollTimer);
|
||||||
}
|
}
|
||||||
else if(this.pollTimer) {
|
|
||||||
clearInterval(this.pollTimer);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enabled: function() {
|
enabled: function() {
|
||||||
return this.config.get("enableTrayNotifications", true);
|
return this.config.get("enableTrayNotifications", true);
|
||||||
},
|
},
|
||||||
stopPolling: function() {
|
stopPolling: function() {
|
||||||
this.config.set("notifySince", this.since.toISOString());
|
this.config.set("storiesNotifySince", this.storiesSince.toISOString());
|
||||||
if(this.pollTimer) {
|
this.config.set("peopleNotifySince", this.peopleSince.toISOString());
|
||||||
clearInterval(this.pollTimer);
|
this.config.set("walletNotifySince", this.walletSince.toISOString());
|
||||||
}
|
this.config.set("marketplaceNotifySince", this.marketplaceSince.toISOString());
|
||||||
|
|
||||||
|
this.enable(false);
|
||||||
},
|
},
|
||||||
_pollToDisableHighlight: function(notifyType, error, data) {
|
_pollToDisableHighlight: function(notifyType, error, data) {
|
||||||
if (error || !data.body) {
|
if (error || !data.body) {
|
||||||
|
@ -172,25 +213,47 @@ HifiNotifications.prototype = {
|
||||||
}
|
}
|
||||||
console.log(content);
|
console.log(content);
|
||||||
if(!content.total_entries) {
|
if(!content.total_entries) {
|
||||||
this.callback(notifyType, false);
|
this.menuNotificationCallback(notifyType, false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_pollCommon: function(notifyType, error, data, since) {
|
_pollCommon: function(notifyType, url, since, finished) {
|
||||||
|
|
||||||
|
var _this = this;
|
||||||
|
IsInterfaceRunning(function(running) {
|
||||||
|
if(running) {
|
||||||
|
finished(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var acctInfo = new AccountInfo();
|
||||||
|
var token = acctInfo.accessToken(METAVERSE_SERVER_URL);
|
||||||
|
if(!token) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
request.get({
|
||||||
|
uri: url,
|
||||||
|
'auth': {
|
||||||
|
'bearer': token
|
||||||
|
}
|
||||||
|
}, function (error, data) {
|
||||||
|
|
||||||
var maxNotificationItemCount = since.getTime() ? MAX_NOTIFICATION_ITEMS : STARTUP_MAX_NOTIFICATION_ITEMS;
|
var maxNotificationItemCount = since.getTime() ? MAX_NOTIFICATION_ITEMS : STARTUP_MAX_NOTIFICATION_ITEMS;
|
||||||
if (error || !data.body) {
|
if (error || !data.body) {
|
||||||
console.log("Error: unable to get " + url);
|
console.log("Error: unable to get " + url);
|
||||||
return false;
|
finished(false);
|
||||||
|
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);
|
||||||
return false;
|
finished(false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
console.log(content);
|
console.log(content);
|
||||||
if(!content.total_entries) {
|
if(!content.total_entries) {
|
||||||
|
finished(true, token);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.callback(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();
|
||||||
|
@ -217,13 +280,14 @@ HifiNotifications.prototype = {
|
||||||
notification.show();
|
notification.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
finished(true, token);
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
pollForStories: function(since, token) {
|
pollForStories: function(since) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var _token = token;
|
|
||||||
var actions = 'announcement';
|
var actions = 'announcement';
|
||||||
var options = [
|
var options = [
|
||||||
'now=' + new Date().toISOString(),
|
|
||||||
'since=' + since.getTime() / 1000,
|
'since=' + since.getTime() / 1000,
|
||||||
'include_actions=announcement',
|
'include_actions=announcement',
|
||||||
'restriction=open,hifi',
|
'restriction=open,hifi',
|
||||||
|
@ -233,13 +297,12 @@ HifiNotifications.prototype = {
|
||||||
console.log("Polling for stories");
|
console.log("Polling for stories");
|
||||||
var url = METAVERSE_SERVER_URL + STORIES_URL + '?' + options.join('&');
|
var url = METAVERSE_SERVER_URL + STORIES_URL + '?' + options.join('&');
|
||||||
console.log(url);
|
console.log(url);
|
||||||
request.get({
|
|
||||||
uri: url,
|
_this._pollCommon(NotificationType.STORIES,
|
||||||
'auth': {
|
url,
|
||||||
'bearer': _token
|
since,
|
||||||
}
|
function (success, token) {
|
||||||
}, function (error, data) {
|
if(success) {
|
||||||
_this._pollCommon(NotificationType.GOTO, error, data, since);
|
|
||||||
var options = [
|
var options = [
|
||||||
'now=' + new Date().toISOString(),
|
'now=' + new Date().toISOString(),
|
||||||
'include_actions=announcement',
|
'include_actions=announcement',
|
||||||
|
@ -248,19 +311,26 @@ HifiNotifications.prototype = {
|
||||||
'per_page=1'
|
'per_page=1'
|
||||||
];
|
];
|
||||||
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
|
||||||
|
// put out the light.
|
||||||
request.get({
|
request.get({
|
||||||
uri: url,
|
uri: url,
|
||||||
'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, token) {
|
pollForConnections: function(since) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var _since = since;
|
var _since = since;
|
||||||
|
IsInterfaceRunning(function(running) {
|
||||||
|
if(running) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var options = [
|
var options = [
|
||||||
'filter=connections',
|
'filter=connections',
|
||||||
'status=online',
|
'status=online',
|
||||||
|
@ -270,6 +340,11 @@ HifiNotifications.prototype = {
|
||||||
console.log("Polling for connections");
|
console.log("Polling for connections");
|
||||||
var url = METAVERSE_SERVER_URL + USERS_URL + '?' + options.join('&');
|
var url = METAVERSE_SERVER_URL + USERS_URL + '?' + options.join('&');
|
||||||
console.log(url);
|
console.log(url);
|
||||||
|
var acctInfo = new AccountInfo();
|
||||||
|
var token = acctInfo.accessToken(METAVERSE_SERVER_URL);
|
||||||
|
if(!token) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
request.get({
|
request.get({
|
||||||
uri: url,
|
uri: url,
|
||||||
'auth': {
|
'auth': {
|
||||||
|
@ -277,7 +352,7 @@ HifiNotifications.prototype = {
|
||||||
}
|
}
|
||||||
}, function (error, data) {
|
}, function (error, data) {
|
||||||
// Users is a special case as we keep track of online users locally.
|
// Users is a special case as we keep track of online users locally.
|
||||||
var maxNotificationItemCount = since.getTime() ? MAX_NOTIFICATION_ITEMS : STARTUP_MAX_NOTIFICATION_ITEMS;
|
var maxNotificationItemCount = _since.getTime() ? MAX_NOTIFICATION_ITEMS : STARTUP_MAX_NOTIFICATION_ITEMS;
|
||||||
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;
|
||||||
|
@ -289,25 +364,38 @@ HifiNotifications.prototype = {
|
||||||
}
|
}
|
||||||
console.log(content);
|
console.log(content);
|
||||||
if(!content.total_entries) {
|
if(!content.total_entries) {
|
||||||
_this.callback(NotificationType.PEOPLE, false);
|
_this.menuNotificationCallback(NotificationType.PEOPLE, false);
|
||||||
_this.onlineUsers = new Set([]);
|
_this.onlineUsers = new Set([]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentUsers = new Set([]);
|
var currentUsers = 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)) {
|
||||||
_this.callback(NotificationType.PEOPLE, true);
|
newUsers.add(user);
|
||||||
_this.onlineUsers.add(user.username);
|
_this.onlineUsers.add(user.username);
|
||||||
var notification = new HifiNotification(NotificationType.PEOPLE, user);
|
|
||||||
notification.show();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_this.onlineUsers = currentUsers;
|
_this.onlineUsers = currentUsers;
|
||||||
|
if(newUsers.size) {
|
||||||
|
_this.menuNotificationCallback(NotificationType.PEOPLE, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(newUsers.size >= maxNotificationItemCount) {
|
||||||
|
var notification = new HifiNotification(NotificationType.PEOPLE, newUsers.size);
|
||||||
|
notification.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
newUsers.forEach(function(user) {
|
||||||
|
var notification = new HifiNotification(NotificationType.PEOPLE, user);
|
||||||
|
notification.show();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pollForEconomicActivity: function(since, token) {
|
pollForEconomicActivity: function(since) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var options = [
|
var options = [
|
||||||
'since=' + since.getTime() / 1000,
|
'since=' + since.getTime() / 1000,
|
||||||
|
@ -319,16 +407,9 @@ HifiNotifications.prototype = {
|
||||||
console.log("Polling for economic activity");
|
console.log("Polling for economic activity");
|
||||||
var url = METAVERSE_SERVER_URL + ECONOMIC_ACTIVITY_URL + '?' + options.join('&');
|
var url = METAVERSE_SERVER_URL + ECONOMIC_ACTIVITY_URL + '?' + options.join('&');
|
||||||
console.log(url);
|
console.log(url);
|
||||||
request.post({
|
_this._pollCommon(NotificationType.WALLET, url, since, function () {});
|
||||||
uri: url,
|
|
||||||
'auth': {
|
|
||||||
'bearer': token
|
|
||||||
}
|
|
||||||
}, function (error, data) {
|
|
||||||
_this._pollCommon(NotificationType.WALLET, error, data, since);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
pollForMarketplaceUpdates: function(since, token) {
|
pollForMarketplaceUpdates: function(since) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var options = [
|
var options = [
|
||||||
'since=' + since.getTime() / 1000,
|
'since=' + since.getTime() / 1000,
|
||||||
|
@ -338,13 +419,21 @@ HifiNotifications.prototype = {
|
||||||
console.log("Polling for marketplace update");
|
console.log("Polling for marketplace update");
|
||||||
var url = METAVERSE_SERVER_URL + UPDATES_URL + '?' + options.join('&');
|
var url = METAVERSE_SERVER_URL + UPDATES_URL + '?' + options.join('&');
|
||||||
console.log(url);
|
console.log(url);
|
||||||
request.put({
|
_this._pollCommon(NotificationType.MARKETPLACE, url, since, function (success, token) {
|
||||||
|
if(success) {
|
||||||
|
var options = [
|
||||||
|
'page=1',
|
||||||
|
'per_page=1'
|
||||||
|
];
|
||||||
|
request.get({
|
||||||
uri: url,
|
uri: url,
|
||||||
'auth': {
|
'auth': {
|
||||||
'bearer': token
|
'bearer': token
|
||||||
}
|
}
|
||||||
}, function(error, data) {
|
}, function(error, data) {
|
||||||
_this._pollCommon(NotificationType.MARKETPLACE, error, data, since);
|
_this._pollToDisableHighlight(NotificationType.MARKETPLACE, error, data);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue