mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 06:46:04 +02:00
use Map() on API.notification and rename it to cachedNotifications
This commit is contained in:
+9
-9
@@ -1546,11 +1546,11 @@ if (window.CefSharp) {
|
|||||||
|
|
||||||
// API: Notification
|
// API: Notification
|
||||||
|
|
||||||
API.notification = {};
|
API.cachedNotifications = new Map();
|
||||||
API.isNotificationLoading = false;
|
API.isNotificationLoading = false;
|
||||||
|
|
||||||
API.$on('LOGIN', function () {
|
API.$on('LOGIN', function () {
|
||||||
this.notification = {};
|
this.cachedNotifications.clear();
|
||||||
this.isNotificationLoading = false;
|
this.isNotificationLoading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1570,7 +1570,7 @@ if (window.CefSharp) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
API.$on('NOTIFICATION:ACCEPT', function (args) {
|
API.$on('NOTIFICATION:ACCEPT', function (args) {
|
||||||
var ctx = this.notification[args.param.notificationId];
|
var ctx = this.cachedNotifications.get(args.param.notificationId);
|
||||||
if (ctx &&
|
if (ctx &&
|
||||||
!ctx.$isExpired) {
|
!ctx.$isExpired) {
|
||||||
ctx.$isExpired = true;
|
ctx.$isExpired = true;
|
||||||
@@ -1590,7 +1590,7 @@ if (window.CefSharp) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
API.$on('NOTIFICATION:HIDE', function (args) {
|
API.$on('NOTIFICATION:HIDE', function (args) {
|
||||||
var ctx = this.notification[args.param.notificationId];
|
var ctx = this.cachedNotifications.get(args.param.notificationId);
|
||||||
if (ctx &&
|
if (ctx &&
|
||||||
!ctx.$isExpired) {
|
!ctx.$isExpired) {
|
||||||
ctx.$isExpired = true;
|
ctx.$isExpired = true;
|
||||||
@@ -1606,7 +1606,7 @@ if (window.CefSharp) {
|
|||||||
|
|
||||||
API.markAllNotificationsAsExpired = function () {
|
API.markAllNotificationsAsExpired = function () {
|
||||||
for (var key in this.notification) {
|
for (var key in this.notification) {
|
||||||
var ctx = this.notification[key];
|
var ctx = this.cachedNotifications.get(key);
|
||||||
if (!ctx.$isExpired) {
|
if (!ctx.$isExpired) {
|
||||||
ctx.$isExpired = true;
|
ctx.$isExpired = true;
|
||||||
}
|
}
|
||||||
@@ -1615,7 +1615,7 @@ if (window.CefSharp) {
|
|||||||
|
|
||||||
API.checkExpiredNotifcations = function () {
|
API.checkExpiredNotifcations = function () {
|
||||||
for (var key in this.notification) {
|
for (var key in this.notification) {
|
||||||
var ctx = this.notification[key];
|
var ctx = this.cachedNotifications.get(key);
|
||||||
if (ctx.$isExpired &&
|
if (ctx.$isExpired &&
|
||||||
!ctx.$isExpired) {
|
!ctx.$isExpired) {
|
||||||
ctx.$isExpired = true;
|
ctx.$isExpired = true;
|
||||||
@@ -1652,7 +1652,7 @@ if (window.CefSharp) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
API.updateNotification = function (ref) {
|
API.updateNotification = function (ref) {
|
||||||
var ctx = this.notification[ref.id];
|
var ctx = this.cachedNotifications.get(ref.id);
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
Object.assign(ctx, ref);
|
Object.assign(ctx, ref);
|
||||||
} else {
|
} else {
|
||||||
@@ -1670,7 +1670,7 @@ if (window.CefSharp) {
|
|||||||
//
|
//
|
||||||
...ref
|
...ref
|
||||||
};
|
};
|
||||||
this.notification[ctx.id] = ctx;
|
this.cachedNotifications.set(ctx.id, ctx);
|
||||||
}
|
}
|
||||||
if (isObject(ctx.details)) {
|
if (isObject(ctx.details)) {
|
||||||
var details = {};
|
var details = {};
|
||||||
@@ -1785,7 +1785,7 @@ if (window.CefSharp) {
|
|||||||
|
|
||||||
API.getFriendRequest = function (userId) {
|
API.getFriendRequest = function (userId) {
|
||||||
for (var key in this.notification) {
|
for (var key in this.notification) {
|
||||||
var ctx = this.notification[key];
|
var ctx = this.cachedNotifications.get(key);
|
||||||
if (ctx.type === 'friendRequest' &&
|
if (ctx.type === 'friendRequest' &&
|
||||||
ctx.senderUserId === userId &&
|
ctx.senderUserId === userId &&
|
||||||
!ctx.$isExpired) {
|
!ctx.$isExpired) {
|
||||||
|
|||||||
Reference in New Issue
Block a user