Fix friends not being shown in current user instance while traveling

This commit is contained in:
Natsumi
2023-06-03 07:24:19 +12:00
parent fc4d94c279
commit 11d92cabba
2 changed files with 26 additions and 36 deletions

View File

@@ -65,6 +65,7 @@
], ],
"no-inline-comments": 0, "no-inline-comments": 0,
"no-invalid-this": 0, "no-invalid-this": 0,
"no-loop-func": 0,
"no-magic-numbers": 0, "no-magic-numbers": 0,
"no-negated-condition": 0, "no-negated-condition": 0,
"no-plusplus": 0, "no-plusplus": 0,

View File

@@ -15630,14 +15630,9 @@ speechSynthesis.getVoices();
var friendsInInstance = this.lastLocation.friendList; var friendsInInstance = this.lastLocation.friendList;
for (var friend of friendsInInstance.values()) { for (var friend of friendsInInstance.values()) {
// if friend isn't in instance add them // if friend isn't in instance add them
var addUser = true; var addUser = !users.some(function (user) {
for (var k = 0; k < users.length; k++) { return friend.displayName === user.displayName;
var user = users[k]; });
if (friend.displayName === user.displayName) {
addUser = false;
break;
}
}
if (addUser) { if (addUser) {
var ref = API.cachedUsers.get(friend.userId); var ref = API.cachedUsers.get(friend.userId);
if (typeof ref !== 'undefined') { if (typeof ref !== 'undefined') {
@@ -15646,7 +15641,8 @@ speechSynthesis.getVoices();
} }
} }
friendCount = users.length - 1; friendCount = users.length - 1;
} else if (!L.isOffline) { }
if (!L.isOffline) {
for (var friend of this.friends.values()) { for (var friend of this.friends.values()) {
if (typeof friend.ref === 'undefined') { if (typeof friend.ref === 'undefined') {
continue; continue;
@@ -15659,7 +15655,13 @@ speechSynthesis.getVoices();
// don't add offline friends to private instances // don't add offline friends to private instances
continue; 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; friendCount = users.length;
@@ -15851,14 +15853,9 @@ speechSynthesis.getVoices();
if (player.displayName === API.currentUser.displayName) { if (player.displayName === API.currentUser.displayName) {
continue; continue;
} }
var addUser = true; var addUser = !users.some(function (user) {
for (var k = 0; k < users.length; k++) { return player.displayName === user.displayName;
var user = users[k]; });
if (player.displayName === user.displayName) {
addUser = false;
break;
}
}
if (addUser) { if (addUser) {
var ref = API.cachedUsers.get(player.userId); var ref = API.cachedUsers.get(player.userId);
if (typeof ref !== 'undefined') { if (typeof ref !== 'undefined') {
@@ -16800,14 +16797,9 @@ speechSynthesis.getVoices();
instances[instance.id] = instance; instances[instance.id] = instance;
for (var friend of friendsInInstance.values()) { for (var friend of friendsInInstance.values()) {
// if friend isn't in instance add them // if friend isn't in instance add them
var addUser = true; var addUser = !instance.users.some(function (user) {
for (var k = 0; k < instance.users.length; k++) { return friend.displayName === user.displayName;
var user = instance.users[k]; });
if (friend.displayName === user.displayName) {
addUser = false;
break;
}
}
if (addUser) { if (addUser) {
var ref = API.cachedUsers.get(friend.userId); var ref = API.cachedUsers.get(friend.userId);
if (typeof ref !== 'undefined') { if (typeof ref !== 'undefined') {
@@ -16822,7 +16814,8 @@ speechSynthesis.getVoices();
typeof ref.$location === 'undefined' || typeof ref.$location === 'undefined' ||
ref.$location.worldId !== D.id || ref.$location.worldId !== D.id ||
(ref.$location.instanceId === lastLocation$.instanceId && (ref.$location.instanceId === lastLocation$.instanceId &&
playersInInstance.size > 0) playersInInstance.size > 0 &&
ref.location !== 'traveling')
) { ) {
continue; continue;
} }
@@ -16970,14 +16963,9 @@ speechSynthesis.getVoices();
instances[currentLocation] = instance; instances[currentLocation] = instance;
for (var friend of friendsInInstance.values()) { for (var friend of friendsInInstance.values()) {
// if friend isn't in instance add them // if friend isn't in instance add them
var addUser = true; var addUser = !instance.users.some(function (user) {
for (var k = 0; k < instance.users.length; k++) { return friend.displayName === user.displayName;
var user = instance.users[k]; });
if (friend.displayName === user.displayName) {
addUser = false;
break;
}
}
if (addUser) { if (addUser) {
var ref = API.cachedUsers.get(friend.userId); var ref = API.cachedUsers.get(friend.userId);
if (typeof ref !== 'undefined') { if (typeof ref !== 'undefined') {
@@ -16992,7 +16980,8 @@ speechSynthesis.getVoices();
typeof ref.$location === 'undefined' || typeof ref.$location === 'undefined' ||
ref.$location.groupId !== D.id || ref.$location.groupId !== D.id ||
(ref.$location.instanceId === lastLocation$.instanceId && (ref.$location.instanceId === lastLocation$.instanceId &&
playersInInstance.size > 0) playersInInstance.size > 0 &&
ref.location !== 'traveling')
) { ) {
continue; continue;
} }