Instance full indicator

This commit is contained in:
Natsumi
2023-04-22 00:52:09 +12:00
parent 2be1a75fcb
commit e1d3a1d412
3 changed files with 97 additions and 19 deletions

View File

@@ -2299,6 +2299,10 @@ speechSynthesis.getVoices();
var D = $app.userDialog; var D = $app.userDialog;
if ($app.userDialog.visible && D.ref.$location.tag === json.id) { if ($app.userDialog.visible && D.ref.$location.tag === json.id) {
D.instance.occupants = json.n_users; D.instance.occupants = json.n_users;
D.instance.full =
typeof json.hasCapacityForYou !== 'undefined' &&
!json.hasCapacityForYou;
D.instance.json = json;
} }
}); });
@@ -2312,6 +2316,10 @@ speechSynthesis.getVoices();
for (var instance of D.rooms) { for (var instance of D.rooms) {
if (instance.id === json.instanceId) { if (instance.id === json.instanceId) {
instance.occupants = json.n_users; instance.occupants = json.n_users;
instance.full =
typeof json.hasCapacityForYou !== 'undefined' &&
!json.hasCapacityForYou;
instance.json = json;
break; break;
} }
} }
@@ -2328,6 +2336,10 @@ speechSynthesis.getVoices();
for (var instance of D.instances) { for (var instance of D.instances) {
if (instance.id === json.instanceId) { if (instance.id === json.instanceId) {
instance.occupants = json.n_users; instance.occupants = json.n_users;
instance.full =
typeof json.hasCapacityForYou !== 'undefined' &&
!json.hasCapacityForYou;
instance.json = json;
break; break;
} }
} }
@@ -14969,8 +14981,14 @@ speechSynthesis.getVoices();
D.worlds = []; D.worlds = [];
D.instance = { D.instance = {
id: '', id: '',
tag: '',
$location: {},
occupants: 0, occupants: 0,
friendCount: 0 friendCount: 0,
full: false,
users: [],
shortName: '',
json: {}
}; };
D.representedGroup = { D.representedGroup = {
bannerUrl: '', bannerUrl: '',
@@ -15263,14 +15281,27 @@ speechSynthesis.getVoices();
playersInInstance.size > 0 playersInInstance.size > 0
) { ) {
D.instance = { D.instance = {
id: L.tag, id: L.instanceId,
occupants: this.lastLocation.playerList.size tag: L.tag,
$location: L,
occupants: this.lastLocation.playerList.size,
friendCount: 0,
full: false,
users: [],
shortName: '',
json: {}
}; };
} }
if (L.isOffline || L.isPrivate || L.isTraveling || L.worldId === '') { if (L.isOffline || L.isPrivate || L.isTraveling || L.worldId === '') {
D.instance = { D.instance = {
id: L.tag, id: L.instanceId,
occupants: 0 tag: L.tag,
$location: L,
occupants: 0,
full: false,
users: [],
shortName: '',
json: {}
}; };
} }
D.instance.friendCount = friendCount; D.instance.friendCount = friendCount;
@@ -16131,7 +16162,11 @@ speechSynthesis.getVoices();
D.ref = ref; D.ref = ref;
$app.applyWorldDialogInstances(); $app.applyWorldDialogInstances();
for (var room of D.rooms) { for (var room of D.rooms) {
if (room.occupants === 0) { if (
$app.isRealInstance(room.tag) &&
room.tag !== $app.lastLocation.location &&
(room.$location.accessType !== 'public' || room.occupants === 0)
) {
API.getInstance({ API.getInstance({
worldId: D.id, worldId: D.id,
instanceId: room.id instanceId: room.id
@@ -16311,19 +16346,27 @@ speechSynthesis.getVoices();
for (var [id, occupants] of D.ref.instances) { for (var [id, occupants] of D.ref.instances) {
instances[id] = { instances[id] = {
id, id,
tag: `${D.id}:${id}`,
occupants, occupants,
friendCount: 0, friendCount: 0,
users: [] full: false,
users: [],
shortName: '',
json: {}
}; };
} }
var {instanceId, shortName} = D.$location; var {instanceId, shortName} = D.$location;
if (instanceId && typeof instances[instanceId] === 'undefined') { if (instanceId && typeof instances[instanceId] === 'undefined') {
instances[instanceId] = { instances[instanceId] = {
id: instanceId, id: instanceId,
tag: `${D.id}:${instanceId}`,
$location: {},
occupants: 0, occupants: 0,
friendCount: 0, friendCount: 0,
full: false,
users: [],
shortName, shortName,
users: [] json: {}
}; };
} }
var currentLocation = this.lastLocation.location; var currentLocation = this.lastLocation.location;
@@ -16336,9 +16379,14 @@ speechSynthesis.getVoices();
var friendsInInstance = this.lastLocation.friendList; var friendsInInstance = this.lastLocation.friendList;
var instance = { var instance = {
id: lastLocation$.instanceId, id: lastLocation$.instanceId,
tag: currentLocation,
$location: {},
occupants: playersInInstance.size, occupants: playersInInstance.size,
friendCount: friendsInInstance.size, friendCount: friendsInInstance.size,
users: [] full: false,
users: [],
shortName: '',
json: {}
}; };
instances[instance.id] = instance; instances[instance.id] = instance;
var ref = API.cachedUsers.get(API.currentUser.id); var ref = API.cachedUsers.get(API.currentUser.id);
@@ -16381,9 +16429,14 @@ speechSynthesis.getVoices();
if (typeof instance === 'undefined') { if (typeof instance === 'undefined') {
instance = { instance = {
id: instanceId, id: instanceId,
tag: `${D.id}:${instanceId}`,
$location: {},
occupants: 0, occupants: 0,
friendCount: 0, friendCount: 0,
users: [] full: false,
users: [],
shortName: '',
json: {}
}; };
instances[instanceId] = instance; instances[instanceId] = instance;
} }
@@ -16424,10 +16477,16 @@ speechSynthesis.getVoices();
} }
// reuse instance occupants from getInstance // reuse instance occupants from getInstance
for (var room of rooms) { for (var room of rooms) {
if (room.occupants === 0) { if (
$app.isRealInstance(room.tag) &&
room.tag !== $app.lastLocation.location &&
(room.$location.accessType !== 'public' || room.occupants === 0)
) {
for (var instance of D.rooms) { for (var instance of D.rooms) {
if (instance.id === room.id) { if (instance.id === room.id) {
room.occupants = instance.occupants; room.occupants = instance.occupants;
room.full = instance.full;
room.json = instance.json;
break; break;
} }
} }
@@ -16459,9 +16518,13 @@ speechSynthesis.getVoices();
instances[instance.location] = { instances[instance.location] = {
id: instance.instanceId, id: instance.instanceId,
tag: instance.location, tag: instance.location,
$location: {},
occupants: instance.memberCount, occupants: instance.memberCount,
friendCount: 0, friendCount: 0,
users: [] full: false,
users: [],
shortName: '',
json: {}
}; };
} }
} }
@@ -16476,9 +16539,13 @@ speechSynthesis.getVoices();
var instance = { var instance = {
id: lastLocation$.instanceId, id: lastLocation$.instanceId,
tag: currentLocation, tag: currentLocation,
$location: {},
occupants: playersInInstance.size, occupants: playersInInstance.size,
friendCount: friendsInInstance.size, friendCount: friendsInInstance.size,
users: [] full: false,
users: [],
shortName: '',
json: {}
}; };
instances[currentLocation] = instance; instances[currentLocation] = instance;
var ref = API.cachedUsers.get(API.currentUser.id); var ref = API.cachedUsers.get(API.currentUser.id);
@@ -16522,9 +16589,13 @@ speechSynthesis.getVoices();
instance = { instance = {
id: instanceId, id: instanceId,
tag, tag,
$location: {},
occupants: 0, occupants: 0,
friendCount: 0, friendCount: 0,
users: [] full: false,
users: [],
shortName: '',
json: {}
}; };
instances[tag] = instance; instances[tag] = instance;
} }

View File

@@ -1773,10 +1773,11 @@ html
el-tooltip(placement="top" :content="$t('dialog.user.info.launch_invite_tooltip')" :disabled="hideTooltips") el-tooltip(placement="top" :content="$t('dialog.user.info.launch_invite_tooltip')" :disabled="hideTooltips")
launch(:location="userDialog.$location.tag" style="margin-left:5px") launch(:location="userDialog.$location.tag" style="margin-left:5px")
el-tooltip(placement="top" :content="$t('dialog.user.info.self_invite_tooltip')" :disabled="hideTooltips") el-tooltip(placement="top" :content="$t('dialog.user.info.self_invite_tooltip')" :disabled="hideTooltips")
invite-yourself(:location="userDialog.$location.tag" :shortname="userDialog.$location.shortName" style="margin-left:5px") invite-yourself(:location="userDialog.$location.tag" :shortname="userDialog.$location.shortName" style="margin-left:5px" :disabled="typeof userDialog.instance.json.canRequestInvite !== 'undefined' && !userDialog.instance.json.canRequestInvite")
el-tooltip(placement="top" :content="$t('dialog.user.info.refresh_user_count_tooltip')" :disabled="hideTooltips") el-tooltip(placement="top" :content="$t('dialog.user.info.refresh_user_count_tooltip')" :disabled="hideTooltips")
el-button(v-if="userDialog.$location.tag !== lastLocation.location" @click="refreshInstancePlayerCount(userDialog.$location.tag)" size="mini" icon="el-icon-refresh" style="margin-left:5px" circle) el-button(v-if="userDialog.$location.tag !== lastLocation.location" @click="refreshInstancePlayerCount(userDialog.$location.tag)" 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.instance.friendCount > 0") ({{ userDialog.instance.friendCount }})] span(v-if="userDialog.instance.occupants" style="margin-left:5px") {{ userDialog.instance.occupants }} #[template(v-if="userDialog.instance.friendCount > 0") ({{ userDialog.instance.friendCount }})]
span(v-if="userDialog.instance.full" style="margin-left:5px;color:lightcoral") {{ $t('dialog.user.info.instance_full') }}
.x-friend-list(style="flex:1;margin-top:10px;max-height:150px") .x-friend-list(style="flex:1;margin-top:10px;max-height:150px")
.x-friend-item(v-if="userDialog.$location.userId" @click="showUserDialog(userDialog.$location.userId)" class="x-friend-item-border") .x-friend-item(v-if="userDialog.$location.userId" @click="showUserDialog(userDialog.$location.userId)" class="x-friend-item-border")
template(v-if="userDialog.$location.user") template(v-if="userDialog.$location.user")
@@ -2065,10 +2066,11 @@ html
div(style="margin:5px 0") div(style="margin:5px 0")
location-world(:locationobject="room.$location" :currentuserid="API.currentUser.id" :worlddialogshortname="worldDialog.$location.shortName") location-world(:locationobject="room.$location" :currentuserid="API.currentUser.id" :worlddialogshortname="worldDialog.$location.shortName")
el-tooltip(placement="top" :content="$t('dialog.world.instances.self_invite_tooltip')" :disabled="hideTooltips") el-tooltip(placement="top" :content="$t('dialog.world.instances.self_invite_tooltip')" :disabled="hideTooltips")
invite-yourself(:location="room.$location.tag" :shortname="room.$location.shortName" style="margin-left:5px") invite-yourself(:location="room.$location.tag" :shortname="room.$location.shortName" style="margin-left:5px" :disabled="typeof room.json.canRequestInvite !== 'undefined' && !room.json.canRequestInvite")
el-tooltip(placement="top" :content="$t('dialog.world.instances.refresh_user_count_tooltip')" :disabled="hideTooltips") el-tooltip(placement="top" :content="$t('dialog.world.instances.refresh_user_count_tooltip')" :disabled="hideTooltips")
el-button(v-if="room.$location.tag !== lastLocation.location" @click="refreshInstancePlayerCount(room.$location.tag)" size="mini" icon="el-icon-refresh" style="margin-left:5px" circle) el-button(v-if="room.tag !== lastLocation.location" @click="refreshInstancePlayerCount(room.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.friendCount > 0") ({{ room.friendCount }})] span(v-if="room.occupants" style="margin-left:5px") {{ room.occupants }} #[template(v-if="room.friendCount > 0") ({{ room.friendCount }})]
span(v-if="room.full" style="margin-left:5px;color:lightcoral") {{ $t('dialog.world.instances.instance_full') }}
.x-friend-list(style="margin:10px 0;max-height:unset" v-if="room.$location.userId || room.users.length") .x-friend-list(style="margin:10px 0;max-height:unset" v-if="room.$location.userId || room.users.length")
.x-friend-item(v-if="room.$location.userId" @click="showUserDialog(room.$location.userId)" class="x-friend-item-border") .x-friend-item(v-if="room.$location.userId" @click="showUserDialog(room.$location.userId)" class="x-friend-item-border")
template(v-if="room.$location.user") template(v-if="room.$location.user")
@@ -2369,10 +2371,11 @@ html
div(style="margin:5px 0") div(style="margin:5px 0")
location(:location="room.tag") location(:location="room.tag")
el-tooltip(placement="top" content="Invite yourself" :disabled="hideTooltips") el-tooltip(placement="top" content="Invite yourself" :disabled="hideTooltips")
invite-yourself(:location="room.tag" style="margin-left:5px") invite-yourself(:location="room.tag" style="margin-left:5px" :disabled="typeof room.json.canRequestInvite !== 'undefined' && !room.json.canRequestInvite")
el-tooltip(placement="top" content="Refresh player count" :disabled="hideTooltips") el-tooltip(placement="top" content="Refresh player count" :disabled="hideTooltips")
el-button(v-if="room.tag !== lastLocation.location" @click="refreshInstancePlayerCount(room.tag)" size="mini" icon="el-icon-refresh" style="margin-left:5px" circle) el-button(v-if="room.tag !== lastLocation.location" @click="refreshInstancePlayerCount(room.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.friendCount > 0") ({{ room.friendCount }})] span(v-if="room.occupants" style="margin-left:5px") {{ room.occupants }} #[template(v-if="room.friendCount > 0") ({{ room.friendCount }})]
span(v-if="room.full" style="margin-left:5px;color:lightcoral") {{ $t('dialog.group.info.instance_full') }}
.x-friend-list(style="margin:10px 0;padding:0;max-height:unset" v-if="room.users.length") .x-friend-list(style="margin:10px 0;padding:0;max-height:unset" v-if="room.users.length")
.x-friend-item(v-for="user in room.users" :key="user.id" @click="showUserDialog(user.id)" class="x-friend-item-border") .x-friend-item(v-for="user in room.users" :key="user.id" @click="showUserDialog(user.id)" class="x-friend-item-border")
.avatar(:class="userStatusClass(user)") .avatar(:class="userStatusClass(user)")

View File

@@ -547,7 +547,8 @@
"avatar_cloning_allow": "Allowed", "avatar_cloning_allow": "Allowed",
"avatar_cloning_deny": "Deny", "avatar_cloning_deny": "Deny",
"home_location": "Home Location", "home_location": "Home Location",
"accuracy_notice": "Info from local database may not be accurate" "accuracy_notice": "Info from local database may not be accurate",
"instance_full": "full"
}, },
"groups": { "groups": {
"header": "Groups", "header": "Groups",
@@ -612,6 +613,7 @@
"capacity_count": "Capacity {count} ({max})", "capacity_count": "Capacity {count} ({max})",
"self_invite_tooltip": "Invite Yourself", "self_invite_tooltip": "Invite Yourself",
"refresh_user_count_tooltip": "Refresh User Count", "refresh_user_count_tooltip": "Refresh User Count",
"instance_full": "full",
"instance_creator": "Instance Creator" "instance_creator": "Instance Creator"
}, },
"info": { "info": {
@@ -722,6 +724,7 @@
"info": { "info": {
"header": "Info", "header": "Info",
"announcement": "Announcement", "announcement": "Announcement",
"instance_full": "full",
"rules": "Rules", "rules": "Rules",
"members": "Members", "members": "Members",
"created_at": "Created At", "created_at": "Created At",
@@ -732,6 +735,7 @@
"id_tooltip": "Copy ID to clipboard", "id_tooltip": "Copy ID to clipboard",
"joined_at": "Joined At", "joined_at": "Joined At",
"roles": "Roles", "roles": "Roles",
"role": "Role:",
"role_description": "Description:", "role_description": "Description:",
"role_updated_at": "Updated At:", "role_updated_at": "Updated At:",
"role_created_at": "Created At:", "role_created_at": "Created At:",