From 11d92cabbac14e08534200e209a22698693ea2e2 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Sat, 3 Jun 2023 07:24:19 +1200 Subject: [PATCH] Fix friends not being shown in current user instance while traveling --- html/.eslintrc.json | 1 + html/src/app.js | 61 +++++++++++++++++++-------------------------- 2 files changed, 26 insertions(+), 36 deletions(-) diff --git a/html/.eslintrc.json b/html/.eslintrc.json index 9d90a309..20cfa458 100644 --- a/html/.eslintrc.json +++ b/html/.eslintrc.json @@ -65,6 +65,7 @@ ], "no-inline-comments": 0, "no-invalid-this": 0, + "no-loop-func": 0, "no-magic-numbers": 0, "no-negated-condition": 0, "no-plusplus": 0, diff --git a/html/src/app.js b/html/src/app.js index 45e5918d..4022e9ea 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -15630,14 +15630,9 @@ speechSynthesis.getVoices(); var friendsInInstance = this.lastLocation.friendList; for (var friend of friendsInInstance.values()) { // if friend isn't in instance add them - var addUser = true; - for (var k = 0; k < users.length; k++) { - var user = users[k]; - if (friend.displayName === user.displayName) { - addUser = false; - break; - } - } + var addUser = !users.some(function (user) { + return friend.displayName === user.displayName; + }); if (addUser) { var ref = API.cachedUsers.get(friend.userId); if (typeof ref !== 'undefined') { @@ -15646,7 +15641,8 @@ speechSynthesis.getVoices(); } } friendCount = users.length - 1; - } else if (!L.isOffline) { + } + if (!L.isOffline) { for (var friend of this.friends.values()) { if (typeof friend.ref === 'undefined') { continue; @@ -15659,7 +15655,13 @@ speechSynthesis.getVoices(); // don't add offline friends to private instances continue; } - users.push(friend.ref); + // if friend isn't in instance add them + var addUser = !users.some(function (user) { + return friend.name === user.displayName; + }); + if (addUser) { + users.push(friend.ref); + } } } friendCount = users.length; @@ -15851,14 +15853,9 @@ speechSynthesis.getVoices(); if (player.displayName === API.currentUser.displayName) { continue; } - var addUser = true; - for (var k = 0; k < users.length; k++) { - var user = users[k]; - if (player.displayName === user.displayName) { - addUser = false; - break; - } - } + var addUser = !users.some(function (user) { + return player.displayName === user.displayName; + }); if (addUser) { var ref = API.cachedUsers.get(player.userId); if (typeof ref !== 'undefined') { @@ -16800,14 +16797,9 @@ speechSynthesis.getVoices(); instances[instance.id] = instance; for (var friend of friendsInInstance.values()) { // if friend isn't in instance add them - var addUser = true; - for (var k = 0; k < instance.users.length; k++) { - var user = instance.users[k]; - if (friend.displayName === user.displayName) { - addUser = false; - break; - } - } + var addUser = !instance.users.some(function (user) { + return friend.displayName === user.displayName; + }); if (addUser) { var ref = API.cachedUsers.get(friend.userId); if (typeof ref !== 'undefined') { @@ -16822,7 +16814,8 @@ speechSynthesis.getVoices(); typeof ref.$location === 'undefined' || ref.$location.worldId !== D.id || (ref.$location.instanceId === lastLocation$.instanceId && - playersInInstance.size > 0) + playersInInstance.size > 0 && + ref.location !== 'traveling') ) { continue; } @@ -16970,14 +16963,9 @@ speechSynthesis.getVoices(); instances[currentLocation] = instance; for (var friend of friendsInInstance.values()) { // if friend isn't in instance add them - var addUser = true; - for (var k = 0; k < instance.users.length; k++) { - var user = instance.users[k]; - if (friend.displayName === user.displayName) { - addUser = false; - break; - } - } + var addUser = !instance.users.some(function (user) { + return friend.displayName === user.displayName; + }); if (addUser) { var ref = API.cachedUsers.get(friend.userId); if (typeof ref !== 'undefined') { @@ -16992,7 +16980,8 @@ speechSynthesis.getVoices(); typeof ref.$location === 'undefined' || ref.$location.groupId !== D.id || (ref.$location.instanceId === lastLocation$.instanceId && - playersInInstance.size > 0) + playersInInstance.size > 0 && + ref.location !== 'traveling') ) { continue; }