Remove self from friend count

This commit is contained in:
Natsumi
2021-10-10 21:18:37 +13:00
parent 7f431231fe
commit cf2341198f
2 changed files with 23 additions and 16 deletions
+21 -14
View File
@@ -1421,6 +1421,9 @@ speechSynthesis.getVoices();
$trustColor: 'x-tag-untrusted', $trustColor: 'x-tag-untrusted',
$trustSortNum: 1, $trustSortNum: 1,
$languages: [], $languages: [],
$joinCount: 0,
$timeSpent: 0,
$lastSeen: '',
// //
...json ...json
}; };
@@ -1862,10 +1865,7 @@ speechSynthesis.getVoices();
var {json} = args; var {json} = args;
var D = $app.userDialog; var D = $app.userDialog;
if ($app.userDialog.visible && D.ref.location === json.id) { if ($app.userDialog.visible && D.ref.location === json.id) {
D.instance = { D.instance.occupants = json.n_users;
id: json.id,
occupants: json.n_users
};
} }
}); });
@@ -7033,10 +7033,7 @@ speechSynthesis.getVoices();
joinTime: Date.parse(ctx.created_at) joinTime: Date.parse(ctx.created_at)
}; };
this.lastLocation.playerList.set(ctx.displayName, userMap); this.lastLocation.playerList.set(ctx.displayName, userMap);
if ( if (this.friends.has(ctx.userId)) {
this.friends.has(ctx.userId) ||
API.currentUser.displayName === ctx.displayName
) {
this.lastLocation.friendList.set( this.lastLocation.friendList.set(
ctx.displayName, ctx.displayName,
userMap userMap
@@ -7562,10 +7559,7 @@ speechSynthesis.getVoices();
gameLog.userDisplayName, gameLog.userDisplayName,
userMap userMap
); );
if ( if (this.friends.has(userId)) {
this.friends.has(userId) ||
API.currentUser.displayName === gameLog.userDisplayName
) {
this.lastLocation.friendList.set( this.lastLocation.friendList.set(
gameLog.userDisplayName, gameLog.userDisplayName,
userMap userMap
@@ -10429,7 +10423,11 @@ speechSynthesis.getVoices();
D.loading = true; D.loading = true;
D.avatars = []; D.avatars = [];
D.worlds = []; D.worlds = [];
D.instance = {}; D.instance = {
id: '',
occupants: 0,
friendCount: 0
};
D.lastSeen = ''; D.lastSeen = '';
D.joinCount = 0; D.joinCount = 0;
D.timeSpent = ''; D.timeSpent = '';
@@ -10551,6 +10549,7 @@ speechSynthesis.getVoices();
} }
} }
var users = []; var users = [];
var friendCount = 0;
var playersInInstance = this.lastLocation.playerList; var playersInInstance = this.lastLocation.playerList;
if ( if (
this.lastLocation.location === L.tag && this.lastLocation.location === L.tag &&
@@ -10578,6 +10577,7 @@ speechSynthesis.getVoices();
users.push(API.cachedUsers.get(friend.userId)); users.push(API.cachedUsers.get(friend.userId));
} }
} }
friendCount = users.length - 1;
} else if (L.isOffline === false) { } else if (L.isOffline === false) {
for (var friend of this.friends.values()) { for (var friend of this.friends.values()) {
if ( if (
@@ -10593,6 +10593,7 @@ speechSynthesis.getVoices();
users.push(friend.ref); users.push(friend.ref);
} }
} }
friendCount = users.length;
} }
users.sort(compareByLocationAt); users.sort(compareByLocationAt);
D.users = users; D.users = users;
@@ -10608,6 +10609,7 @@ speechSynthesis.getVoices();
occupants: 0 occupants: 0
}; };
} }
D.instance.friendCount = friendCount;
}; };
$app.methods.setUserDialogWorlds = function (userId) { $app.methods.setUserDialogWorlds = function (userId) {
@@ -11178,6 +11180,7 @@ speechSynthesis.getVoices();
instances[id] = { instances[id] = {
id, id,
occupants, occupants,
friendCount: 0,
users: [] users: []
}; };
} }
@@ -11186,15 +11189,18 @@ speechSynthesis.getVoices();
instances[instanceId] = { instances[instanceId] = {
id: instanceId, id: instanceId,
occupants: 0, occupants: 0,
friendCount: 0,
users: [] users: []
}; };
} }
var lastLocation$ = API.parseLocation(this.lastLocation.location); var lastLocation$ = API.parseLocation(this.lastLocation.location);
var playersInInstance = this.lastLocation.playerList; var playersInInstance = this.lastLocation.playerList;
if (lastLocation$.worldId === D.id) { if (lastLocation$.worldId === D.id) {
var friendsInInstance = this.lastLocation.friendList;
var instance = { var instance = {
id: lastLocation$.instanceId, id: lastLocation$.instanceId,
occupants: playersInInstance.size, occupants: playersInInstance.size,
friendCount: friendsInInstance.size,
users: [] users: []
}; };
instances[instance.id] = instance; instances[instance.id] = instance;
@@ -11205,7 +11211,6 @@ speechSynthesis.getVoices();
if (playersInInstance.has(ref.displayName)) { if (playersInInstance.has(ref.displayName)) {
instance.users.push(ref); // add self instance.users.push(ref); // add self
} }
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 = true;
@@ -11239,6 +11244,7 @@ speechSynthesis.getVoices();
instance = { instance = {
id: instanceId, id: instanceId,
occupants: 0, occupants: 0,
friendCount: 0,
users: [] users: []
}; };
instances[instanceId] = instance; instances[instanceId] = instance;
@@ -11265,6 +11271,7 @@ speechSynthesis.getVoices();
L.user = ref; L.user = ref;
} }
} }
instance.friendCount = instance.users.length;
instance.users.sort(compareByLocationAt); instance.users.sort(compareByLocationAt);
rooms.push(instance); rooms.push(instance);
} }
+2 -2
View File
@@ -1210,7 +1210,7 @@ html
el-button(v-if="copyLocationCheck(userDialog.ref.location)" @click="copyLocation(userDialog.ref.location)" size="mini" icon="el-icon-s-order" style="margin-left:5px" circle) el-button(v-if="copyLocationCheck(userDialog.ref.location)" @click="copyLocation(userDialog.ref.location)" size="mini" icon="el-icon-s-order" style="margin-left:5px" circle)
el-tooltip(placement="top" content="Refresh player count" :disabled="hideTooltips") el-tooltip(placement="top" content="Refresh player count" :disabled="hideTooltips")
el-button(@click="refreshInstancePlayerCount(userDialog.ref.location)" size="mini" icon="el-icon-refresh" style="margin-left:5px" circle) el-button(@click="refreshInstancePlayerCount(userDialog.ref.location)" size="mini" icon="el-icon-refresh" style="margin-left:5px" circle)
span(v-if="userDialog.instance.occupants" style="margin-left:5px") {{ userDialog.instance.occupants }} #[template(v-if="userDialog.users.length > 0") ({{ userDialog.users.length }})] span(v-if="userDialog.instance.occupants" style="margin-left:5px") {{ userDialog.instance.occupants }} #[template(v-if="userDialog.instance.friendCount > 0") ({{ userDialog.instance.friendCount }})]
.x-friend-list(style="flex:1;margin-top:10px") .x-friend-list(style="flex:1;margin-top:10px")
.x-friend-item(v-if="userDialog.$location.userId" @click="showUserDialog(userDialog.$location.userId)") .x-friend-item(v-if="userDialog.$location.userId" @click="showUserDialog(userDialog.$location.userId)")
template(v-if="userDialog.$location.user") template(v-if="userDialog.$location.user")
@@ -1411,7 +1411,7 @@ html
el-button(v-if="copyLocationCheck(room.$location.tag)" @click="copyLocation(room.$location.tag)" size="mini" icon="el-icon-s-order" style="margin-left:5px" circle) el-button(v-if="copyLocationCheck(room.$location.tag)" @click="copyLocation(room.$location.tag)" size="mini" icon="el-icon-s-order" style="margin-left:5px" circle)
el-tooltip(placement="top" content="Refresh player count" :disabled="hideTooltips") el-tooltip(placement="top" content="Refresh player count" :disabled="hideTooltips")
el-button(@click="refreshInstancePlayerCount(room.$location.tag)" size="mini" icon="el-icon-refresh" style="margin-left:5px" circle) el-button(@click="refreshInstancePlayerCount(room.$location.tag)" size="mini" icon="el-icon-refresh" style="margin-left:5px" circle)
span(v-if="room.occupants" style="margin-left:5px") {{ room.occupants }} #[template(v-if="room.users.length > 0") ({{ room.users.length }})] span(v-if="room.occupants" style="margin-left:5px") {{ room.occupants }} #[template(v-if="room.friendCount > 0") ({{ room.friendCount }})]
.x-friend-list(style="margin:10px 0" v-if="room.$location.userId || room.users.length") .x-friend-list(style="margin:10px 0" v-if="room.$location.userId || room.users.length")
.x-friend-item(v-if="room.$location.userId" @click="showUserDialog(room.$location.userId)") .x-friend-item(v-if="room.$location.userId" @click="showUserDialog(room.$location.userId)")
template(v-if="room.$location.user") template(v-if="room.$location.user")