From bc2924abc6067d8ffb932c9ce1f91bdacde26ebd Mon Sep 17 00:00:00 2001 From: pypy Date: Sat, 11 Jan 2020 23:37:21 +0900 Subject: [PATCH] use Map() on API.notification and rename it to cachedNotifications --- html/app.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/html/app.js b/html/app.js index 4f0cc647..dd0c8d3e 100644 --- a/html/app.js +++ b/html/app.js @@ -1546,11 +1546,11 @@ if (window.CefSharp) { // API: Notification - API.notification = {}; + API.cachedNotifications = new Map(); API.isNotificationLoading = false; API.$on('LOGIN', function () { - this.notification = {}; + this.cachedNotifications.clear(); this.isNotificationLoading = false; }); @@ -1570,7 +1570,7 @@ if (window.CefSharp) { }); API.$on('NOTIFICATION:ACCEPT', function (args) { - var ctx = this.notification[args.param.notificationId]; + var ctx = this.cachedNotifications.get(args.param.notificationId); if (ctx && !ctx.$isExpired) { ctx.$isExpired = true; @@ -1590,7 +1590,7 @@ if (window.CefSharp) { }); API.$on('NOTIFICATION:HIDE', function (args) { - var ctx = this.notification[args.param.notificationId]; + var ctx = this.cachedNotifications.get(args.param.notificationId); if (ctx && !ctx.$isExpired) { ctx.$isExpired = true; @@ -1606,7 +1606,7 @@ if (window.CefSharp) { API.markAllNotificationsAsExpired = function () { for (var key in this.notification) { - var ctx = this.notification[key]; + var ctx = this.cachedNotifications.get(key); if (!ctx.$isExpired) { ctx.$isExpired = true; } @@ -1615,7 +1615,7 @@ if (window.CefSharp) { API.checkExpiredNotifcations = function () { for (var key in this.notification) { - var ctx = this.notification[key]; + var ctx = this.cachedNotifications.get(key); if (ctx.$isExpired && !ctx.$isExpired) { ctx.$isExpired = true; @@ -1652,7 +1652,7 @@ if (window.CefSharp) { }; API.updateNotification = function (ref) { - var ctx = this.notification[ref.id]; + var ctx = this.cachedNotifications.get(ref.id); if (ctx) { Object.assign(ctx, ref); } else { @@ -1670,7 +1670,7 @@ if (window.CefSharp) { // ...ref }; - this.notification[ctx.id] = ctx; + this.cachedNotifications.set(ctx.id, ctx); } if (isObject(ctx.details)) { var details = {}; @@ -1785,7 +1785,7 @@ if (window.CefSharp) { API.getFriendRequest = function (userId) { for (var key in this.notification) { - var ctx = this.notification[key]; + var ctx = this.cachedNotifications.get(key); if (ctx.type === 'friendRequest' && ctx.senderUserId === userId && !ctx.$isExpired) {