mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 22:46:06 +02:00
using Map instead of object on API.world and renaming it to API.cachedWorlds
This commit is contained in:
+10
-10
@@ -615,7 +615,7 @@ if (window.CefSharp) {
|
|||||||
} else if (L.isPrivate) {
|
} else if (L.isPrivate) {
|
||||||
this.text = 'Private';
|
this.text = 'Private';
|
||||||
} else if (L.worldId) {
|
} else if (L.worldId) {
|
||||||
var ref = API.world[L.worldId];
|
var ref = API.cachedWorlds.get(L.worldId);
|
||||||
if (ref) {
|
if (ref) {
|
||||||
if (L.instanceId) {
|
if (L.instanceId) {
|
||||||
this.text = `${ref.name} #${L.instanceName} ${L.accessType}`;
|
this.text = `${ref.name} #${L.instanceName} ${L.accessType}`;
|
||||||
@@ -1086,7 +1086,7 @@ if (window.CefSharp) {
|
|||||||
|
|
||||||
// API: World
|
// API: World
|
||||||
|
|
||||||
API.world = {};
|
API.cachedWorlds = new Map();
|
||||||
|
|
||||||
API.$on('WORLD', function (args) {
|
API.$on('WORLD', function (args) {
|
||||||
args.ref = this.updateWorld(args.json);
|
args.ref = this.updateWorld(args.json);
|
||||||
@@ -1122,7 +1122,7 @@ if (window.CefSharp) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
API.updateWorld = function (ref) {
|
API.updateWorld = function (ref) {
|
||||||
var ctx = this.world[ref.id];
|
var ctx = this.cachedWorlds.get(ref.id);
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
Object.assign(ctx, ref);
|
Object.assign(ctx, ref);
|
||||||
} else {
|
} else {
|
||||||
@@ -1163,7 +1163,7 @@ if (window.CefSharp) {
|
|||||||
//
|
//
|
||||||
...ref
|
...ref
|
||||||
};
|
};
|
||||||
this.world[ctx.id] = ctx;
|
this.cachedWorlds.set(ctx.id, ctx);
|
||||||
}
|
}
|
||||||
if (ctx.tags) {
|
if (ctx.tags) {
|
||||||
ctx.labs_ = ctx.tags.includes('system_labs');
|
ctx.labs_ = ctx.tags.includes('system_labs');
|
||||||
@@ -1178,7 +1178,7 @@ if (window.CefSharp) {
|
|||||||
*/
|
*/
|
||||||
API.getCachedWorld = function (param) {
|
API.getCachedWorld = function (param) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var ctx = this.world[param.worldId];
|
var ctx = this.cachedWorlds.get(param.worldId);
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
resolve({
|
resolve({
|
||||||
cache: true,
|
cache: true,
|
||||||
@@ -4592,7 +4592,7 @@ if (window.CefSharp) {
|
|||||||
L.worldName = L.worldId;
|
L.worldName = L.worldId;
|
||||||
this.lastLocation_ = L;
|
this.lastLocation_ = L;
|
||||||
if (L.worldId) {
|
if (L.worldId) {
|
||||||
var ref = API.world[L.worldId];
|
var ref = API.cachedWorlds.get(L.worldId);
|
||||||
if (ref) {
|
if (ref) {
|
||||||
L.worldName = ref.name;
|
L.worldName = ref.name;
|
||||||
} else {
|
} else {
|
||||||
@@ -4918,7 +4918,7 @@ if (window.CefSharp) {
|
|||||||
} else if (type === 'world') {
|
} else if (type === 'world') {
|
||||||
var ctx = this.favoriteWorld[objectId];
|
var ctx = this.favoriteWorld[objectId];
|
||||||
if (favorite) {
|
if (favorite) {
|
||||||
var ref = API.world[objectId];
|
var ref = API.cachedWorlds.get(objectId);
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
if (ctx.ref !== ref) {
|
if (ctx.ref !== ref) {
|
||||||
ctx.ref = ref;
|
ctx.ref = ref;
|
||||||
@@ -5885,7 +5885,7 @@ if (window.CefSharp) {
|
|||||||
D.isWorldsLoading = false;
|
D.isWorldsLoading = false;
|
||||||
D.isAvatarsLoading = false;
|
D.isAvatarsLoading = false;
|
||||||
for (var key in API.world) {
|
for (var key in API.world) {
|
||||||
var ref = API.world[key];
|
var ref = API.cachedWorlds.get(key);
|
||||||
if (ref.authorId === D.id) {
|
if (ref.authorId === D.id) {
|
||||||
D.worlds.push(ref);
|
D.worlds.push(ref);
|
||||||
}
|
}
|
||||||
@@ -5963,7 +5963,7 @@ if (window.CefSharp) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var ref = API.world[L.worldId];
|
var ref = API.cachedWorlds.get(L.worldId);
|
||||||
if (ref) {
|
if (ref) {
|
||||||
handle(ref.instances);
|
handle(ref.instances);
|
||||||
} else {
|
} else {
|
||||||
@@ -6726,7 +6726,7 @@ if (window.CefSharp) {
|
|||||||
D.worldName = ref.name;
|
D.worldName = ref.name;
|
||||||
D.visible = true;
|
D.visible = true;
|
||||||
};
|
};
|
||||||
var ref = API.world[L.worldId];
|
var ref = API.cachedWorlds.get(L.worldId);
|
||||||
if (ref) {
|
if (ref) {
|
||||||
handle(ref);
|
handle(ref);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user