mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-22 16:23:50 +02:00
use Map() on API.playerModeration and rename it to cachedPlayerModerations
This commit is contained in:
20
html/app.js
20
html/app.js
@@ -1794,11 +1794,11 @@ if (window.CefSharp) {
|
|||||||
|
|
||||||
// API: PlayerModeration
|
// API: PlayerModeration
|
||||||
|
|
||||||
API.playerModeration = {};
|
API.cachedPlayerModerations = new Map();
|
||||||
API.isPlayerModerationLoading = false;
|
API.isPlayerModerationLoading = false;
|
||||||
|
|
||||||
API.$on('LOGIN', function () {
|
API.$on('LOGIN', function () {
|
||||||
this.playerModeration = {};
|
this.cachedPlayerModerations.clear();
|
||||||
this.isPlayerModerationLoading = false;
|
this.isPlayerModerationLoading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1831,8 +1831,7 @@ if (window.CefSharp) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
API.markAllPlayerModerationsAsExpired = function () {
|
API.markAllPlayerModerationsAsExpired = function () {
|
||||||
for (var key in this.playerModeration) {
|
for (var ctx of this.cachedPlayerModerations.values()) {
|
||||||
var ctx = this.playerModeration[key];
|
|
||||||
if (!ctx.$isExpired) {
|
if (!ctx.$isExpired) {
|
||||||
ctx.$isExpired = true;
|
ctx.$isExpired = true;
|
||||||
}
|
}
|
||||||
@@ -1840,8 +1839,7 @@ if (window.CefSharp) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
API.checkExpiredPlayerModerations = function () {
|
API.checkExpiredPlayerModerations = function () {
|
||||||
for (var key in this.playerModeration) {
|
for (var ctx of this.cachedPlayerModerations.values()) {
|
||||||
var ctx = this.playerModeration[key];
|
|
||||||
if (ctx.$isExpired &&
|
if (ctx.$isExpired &&
|
||||||
!ctx.$isExpired) {
|
!ctx.$isExpired) {
|
||||||
ctx.$isExpired = true;
|
ctx.$isExpired = true;
|
||||||
@@ -1872,8 +1870,7 @@ if (window.CefSharp) {
|
|||||||
|
|
||||||
API.handleDeletePlayerModeration = function (type, moderated) {
|
API.handleDeletePlayerModeration = function (type, moderated) {
|
||||||
var cuid = this.currentUser.id;
|
var cuid = this.currentUser.id;
|
||||||
for (var key in this.playerModeration) {
|
for (var ctx of this.cachedPlayerModerations.values()) {
|
||||||
var ctx = this.playerModeration[key];
|
|
||||||
if (ctx.type === type &&
|
if (ctx.type === type &&
|
||||||
ctx.targetUserId === moderated &&
|
ctx.targetUserId === moderated &&
|
||||||
ctx.sourceUserId === cuid &&
|
ctx.sourceUserId === cuid &&
|
||||||
@@ -1890,7 +1887,7 @@ if (window.CefSharp) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
API.updatePlayerModeration = function (ref) {
|
API.updatePlayerModeration = function (ref) {
|
||||||
var ctx = this.playerModeration[ref.id];
|
var ctx = this.cachedPlayerModerations.get(ref.id);
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
Object.assign(ctx, ref);
|
Object.assign(ctx, ref);
|
||||||
} else {
|
} else {
|
||||||
@@ -1907,7 +1904,7 @@ if (window.CefSharp) {
|
|||||||
//
|
//
|
||||||
...ref
|
...ref
|
||||||
};
|
};
|
||||||
this.playerModeration[ctx.id] = ctx;
|
this.cachedPlayerModerations.set(ctx.id, ctx);
|
||||||
}
|
}
|
||||||
ctx.$isExpired = false;
|
ctx.$isExpired = false;
|
||||||
return ctx;
|
return ctx;
|
||||||
@@ -5879,8 +5876,7 @@ if (window.CefSharp) {
|
|||||||
D.isBlock = false;
|
D.isBlock = false;
|
||||||
D.isMute = false;
|
D.isMute = false;
|
||||||
D.isHideAvatar = false;
|
D.isHideAvatar = false;
|
||||||
for (var key in API.playerModeration) {
|
for (var ref of API.cachedPlayerModerations.values()) {
|
||||||
var ref = API.playerModeration[key];
|
|
||||||
if (ref.targetUserId === D.id &&
|
if (ref.targetUserId === D.id &&
|
||||||
ref.sourceUserId === API.currentUser.id &&
|
ref.sourceUserId === API.currentUser.id &&
|
||||||
!ref.$isExpired) {
|
!ref.$isExpired) {
|
||||||
|
|||||||
Reference in New Issue
Block a user