diff --git a/html/src/app.js b/html/src/app.js index 8cd521c6..ef8b32c8 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -1621,7 +1621,8 @@ speechSynthesis.getVoices(); API.$on('INSTANCE', function (args) { var { json } = args; var D = $app.userDialog; - if (D.ref.location === json.id) { + if (($app.userDialog.visible) && + (D.ref.location === json.id)) { D.instance = { id: json.id, occupants: json.n_users @@ -1629,6 +1630,20 @@ speechSynthesis.getVoices(); } }); + API.$on('INSTANCE', function (args) { + var { json } = args; + var D = $app.worldDialog; + if (($app.worldDialog.visible) && + ($app.worldDialog.id === json.worldId)) { + for (var instance of D.rooms) { + if (instance.id === json.instanceId) { + instance.occupants = json.n_users; + break; + } + } + } + }); + // API: Friend API.friends200 = new Set(); @@ -8209,16 +8224,11 @@ speechSynthesis.getVoices(); } } } - } else { - if (L.isOffline === false) { - for (var { ref } of this.friends.values()) { - if (typeof ref !== 'undefined' && - ref.location === L.tag) { - if ((ref.state === 'active') && (ref.location === 'private')) { - continue; - } - users.push(ref); - } + } else if (L.isOffline === false) { + for (var { ref } of this.friends.values()) { + if ((typeof ref !== 'undefined') && + (ref.location === L.tag)) { + users.push(ref); } } } @@ -8470,7 +8480,56 @@ speechSynthesis.getVoices(); if (D.visible === false) { return; } - if (command === 'Add Favorite') { + if (command === 'Refresh') { + D.loading = true; + API.getUser({ + userId: D.id + }).catch((err) => { + D.loading = false; + D.visible = false; + throw err; + }).then((args) => { + if (D.id === args.ref.id) { + D.loading = false; + D.ref = args.ref; + D.friend = this.friends.get(D.id); + D.isFriend = Boolean(D.friend); + D.incomingRequest = false; + D.outgoingRequest = false; + D.isBlock = false; + D.isMute = false; + D.isHideAvatar = false; + for (var ref of API.cachedPlayerModerations.values()) { + if (ref.$isDeleted === false && + ref.targetUserId === D.id && + ref.sourceUserId === API.currentUser.id) { + if (ref.type === 'block') { + D.isBlock = true; + } else if (ref.type === 'mute') { + D.isMute = true; + } else if (ref.type === 'hideAvatar') { + D.isHideAvatar = true; + } + } + } + D.isFavorite = API.cachedFavoritesByObjectId.has(D.id); + this.applyUserDialogLocation(); + API.getFriendStatus({ + userId: D.id + }); + this.getAvatarName(args); + var L = API.parseLocation(D.ref.location); + if ((L.worldId) && + (this.lastLocation.location !== L.tag)) { + API.getInstance({ + worldId: L.worldId, + instanceId: L.instanceId + }); + } + } + return args; + }); + } else if (command === 'Add Favorite') { this.showFavoriteDialog('friend', D.id); } else if (command === 'Edit Social Status') { this.showSocialStatusDialog(); @@ -8599,6 +8658,18 @@ speechSynthesis.getVoices(); } D.ref = ref; $app.applyWorldDialogInstances(); + for (var room of D.rooms) { + if (room.occupants === 0) { + API.getInstance({ + worldId: D.id, + instanceId: room.id + }); + } + } + D.rooms.sort(function (a, b) { + return b.users.length - a.users.length || + b.occupants - a.occupants; + }); if (D.fileSize === 'Loading') { var assetUrl = ''; for (var i = ref.unityPackages.length - 1; i > -1; i--) { @@ -8675,7 +8746,6 @@ speechSynthesis.getVoices(); D.isFavorite = API.cachedFavoritesByObjectId.has(D.id); D.rooms = []; this.updateVRChatCache(); - this.applyWorldDialogInstances(); if (args.cache) { API.getWorld(args.params); } @@ -8709,13 +8779,12 @@ speechSynthesis.getVoices(); var instance = instances[lastLocation$.instanceId]; if (typeof instance === 'undefined') { instance = { - id: lastLocation$.instanceId, - occupants: 1, - users: [] + id: lastLocation$.instanceId, + occupants: playersInInstance.length, + users: [] }; instances[instance.id] = instance; } - instances[instance.id].occupants = playersInInstance.length; var ref = API.cachedUsers.get(API.currentUser.id); if (typeof ref === 'undefined') { ref = API.currentUser; @@ -8810,14 +8879,10 @@ speechSynthesis.getVoices(); throw err; }).then((args) => { if (D.id === args.ref.id) { - D.loading = false; - D.ref = args.ref; - D.isFavorite = API.cachedFavoritesByObjectId.has(D.id); - D.rooms = []; - this.applyWorldDialogInstances(); - if (args.cache) { - API.getWorld(args.params); - } + D.loading = false; + D.ref = args.ref; + D.isFavorite = API.cachedFavoritesByObjectId.has(D.id); + this.updateVRChatCache(); } return args; }); @@ -12016,6 +12081,16 @@ speechSynthesis.getVoices(); }); }; + $app.methods.refreshInstancePlayerCount = function (instance) { + var L = API.parseLocation(instance); + if (L.worldId) { + API.getInstance({ + worldId: L.worldId, + instanceId: L.instanceId + }); + } + }; + $app = new Vue($app); window.$app = $app; }()); diff --git a/html/src/index.pug b/html/src/index.pug index fa14ff90..54b11ca6 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -868,13 +868,13 @@ html div.options-container-item el-button(size="small" icon="el-icon-chat-square" @click="showNotyFeedFiltersDialog()") Notification Filters br - span.sub-header TTS Options + span.sub-header Text-To-Speach Options div.options-container-item span.name Notification TTS, When to play: br toggle-switch(:options="whenToPlayToggleSwitchOption" group="whenToPlayNotificationTTSToggleSwitchOption" v-model="notificationTTS" class="toggle-switch") div.options-container-item - span.name Text-to-Speech Voice + span.name TTS Voice el-dropdown(@command="(voice) => changeTTSVoice(voice)" trigger="click" size="small") el-button(v-text="TTSvoices[notificationTTSVoice].name" size="mini" :disabled="!notificationTTS") el-dropdown-menu(#default="dropdown") @@ -1076,8 +1076,9 @@ html el-dropdown(trigger="click" @command="userDialogCommand" size="small") el-button(:type="(userDialog.incomingRequest || userDialog.outgoingRequest) ? 'success' : (userDialog.isBlock || userDialog.isMute || userDialog.isHideAvatar) ? 'danger' : 'default'" icon="el-icon-more" circle style="margin-left:5px") el-dropdown-menu(#default="dropdown") + el-dropdown-item(icon="el-icon-refresh" command="Refresh") Refresh template(v-if="userDialog.ref.id === API.currentUser.id") - el-dropdown-item(icon="el-icon-check" command="Select Avatar") Select Avatar By ID + el-dropdown-item(icon="el-icon-check" command="Select Avatar" divided) Select Avatar By ID el-dropdown-item(icon="el-icon-s-custom" command="Show Avatar Author") Show Avatar Author el-dropdown-item(icon="el-icon-s-custom" command="Show Fallback Avatar Details") Show Fallback Avatar Details el-dropdown-item(icon="el-icon-edit" command="Edit Social Status" divided) Social Status @@ -1086,11 +1087,11 @@ html el-dropdown-item(icon="el-icon-switch-button" command="Logout" divided) Logout template(v-else) template(v-if="userDialog.isFriend") + el-dropdown-item(icon="el-icon-postcard" command="Request Invite" divided) Request Invite + el-dropdown-item(icon="el-icon-postcard" command="Request Invite Message") Request Invite With Message template(v-if="lastLocation.location && isGameRunning") el-dropdown-item(icon="el-icon-message" command="Invite") Invite el-dropdown-item(icon="el-icon-message" command="Invite Message") Invite With Message - el-dropdown-item(icon="el-icon-postcard" command="Request Invite") Request Invite - el-dropdown-item(icon="el-icon-postcard" command="Request Invite Message") Request Invite With Message template(v-else-if="userDialog.incomingRequest") el-dropdown-item(icon="el-icon-check" command="Accept Friend Request") Accept Friend Request el-dropdown-item(icon="el-icon-close" command="Decline Friend Request") Decline Friend Request @@ -1113,6 +1114,7 @@ html div(style="flex:none") location(:location="userDialog.ref.location") template(#default v-if="userDialog.instance.occupants") ({{ userDialog.instance.occupants }}) + el-button(v-if="userDialog.ref.location !== lastLocation.location && userDialog.ref.location !== 'private' && userDialog.ref.location !== 'offline'" @click="refreshInstancePlayerCount(userDialog.ref.location)" size="mini" icon="el-icon-refresh" style="margin-left:5px" circle) launch(:location="userDialog.ref.location" style="margin-left:5px") invite-yourself(:location="userDialog.ref.location" style="margin-left:5px") 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) @@ -1287,6 +1289,7 @@ html div(style="margin:5px 0") span.x-link(@click="showLaunchDialog(room.$location.tag)"). \#{{ room.$location.instanceName }} {{ room.$location.accessType }} #[template(v-if="room.occupants") ({{ room.occupants }})] + el-button(v-if="room.$location.tag !== lastLocation.location && room.$location.tag !== 'private' && room.$location.tag !== 'offline'" @click="refreshInstancePlayerCount(room.$location.tag)" size="mini" icon="el-icon-refresh" style="margin-left:5px" circle) invite-yourself(:location="room.$location.tag" style="margin-left:5px") 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) .x-friend-list(style="margin:10px 0" v-if="room.$location.userId || room.users.length")