diff --git a/html/src/app.js b/html/src/app.js index c79d8e50..4d8e1403 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -8979,8 +8979,9 @@ speechSynthesis.getVoices(); $app.methods.checkPhotonBotJoin = function (photonId, data, gameLogDate) { var text = ''; var platforms = []; - if (typeof this.currentInstanceWorld.unityPackages === 'object') { - for (var unityPackage of this.currentInstanceWorld.unityPackages) { + if (typeof this.currentInstanceWorld.ref.unityPackages === 'object') { + for (var unityPackage of this.currentInstanceWorld.ref + .unityPackages) { platforms.push(unityPackage.platform); } } @@ -13178,39 +13179,88 @@ speechSynthesis.getVoices(); this.updateTimers(); }; - $app.data.currentInstanceWorld = {}; + $app.data.currentInstanceWorld = { + ref: {}, + isPC: false, + isQuest: false, + inCache: false, + cacheSize: '', + fileCreatedAt: '', + fileSize: '' + }; $app.data.currentInstanceLocation = {}; $app.methods.updateCurrentInstanceWorld = function (instanceId) { - this.currentInstanceWorld = {}; - this.currentInstanceLocation = {}; - if (instanceId) { + if (!instanceId) { + this.currentInstanceWorld = { + ref: {}, + isPC: false, + isQuest: false, + inCache: false, + cacheSize: '', + fileCreatedAt: '', + fileSize: '' + }; + this.currentInstanceLocation = {}; + } else if ( + instanceId !== this.currentInstanceLocation.tag && + this.currentInstanceLocation.tag !== + this.lastLocationDestination + ) { + this.currentInstanceWorld = { + ref: {}, + isPC: false, + isQuest: false, + inCache: false, + cacheSize: '', + fileCreatedAt: '', + fileSize: '' + }; var L = API.parseLocation(instanceId); this.currentInstanceLocation = L; - var ref = API.cachedWorlds.get(L.worldId); - if (!ref) { - API.getCachedWorld({ - worldId: L.worldId - }).then((args) => { - this.currentInstanceWorld = args.ref; - var {isPC, isQuest} = this.getAvailablePlatforms( - args.ref.unityPackages - ); - this.currentInstanceWorld.$isPC = isPC; - this.currentInstanceWorld.$isQuest = isQuest; + API.getWorld({ + worldId: L.worldId + }).then((args) => { + this.currentInstanceWorld.ref = args.ref; + var {isPC, isQuest} = this.getAvailablePlatforms( + args.ref.unityPackages + ); + this.currentInstanceWorld.isPC = isPC; + this.currentInstanceWorld.isQuest = isQuest; + this.checkVRChatCache(args.ref).then((cacheInfo) => { + if (cacheInfo[0] > 0) { + this.currentInstanceWorld.inCache = true; + this.currentInstanceWorld.cacheSize = `${( + cacheInfo[0] / 1048576 + ).toFixed(2)} MiB`; + } }); - } else { - API.getWorld({ - worldId: L.worldId - }).then((args) => { - this.currentInstanceWorld = args.ref; - var {isPC, isQuest} = this.getAvailablePlatforms( - args.ref.unityPackages - ); - this.currentInstanceWorld.$isPC = isPC; - this.currentInstanceWorld.$isQuest = isQuest; + this.getBundleDateSize(args.ref).then( + ({createdAt, fileSize}) => { + this.currentInstanceWorld.fileCreatedAt = createdAt; + this.currentInstanceWorld.fileSize = fileSize; + } + ); + }); + } else { + API.getCachedWorld({ + worldId: this.currentInstanceLocation.worldId + }).then((args) => { + this.currentInstanceWorld.ref = args.ref; + var {isPC, isQuest} = this.getAvailablePlatforms( + args.ref.unityPackages + ); + this.currentInstanceWorld.isPC = isPC; + this.currentInstanceWorld.isQuest = isQuest; + this.checkVRChatCache(args.ref).then((cacheInfo) => { + if (cacheInfo[0] > 0) { + this.currentInstanceWorld.inCache = true; + this.currentInstanceWorld.cacheSize = `${( + cacheInfo[0] / 1048576 + ).toFixed(2)} MiB`; + } }); - } + }); } }; @@ -13726,41 +13776,59 @@ speechSynthesis.getVoices(); return b.users.length - a.users.length || b.occupants - a.occupants; }); if (D.fileSize === 'Loading') { - var assetUrl = ''; - for (let i = ref.unityPackages.length - 1; i > -1; i--) { - var unityPackage = ref.unityPackages[i]; - if ( - unityPackage.platform === 'standalonewindows' && - $app.compareUnityVersion(unityPackage.unityVersion) - ) { - assetUrl = unityPackage.assetUrl; - break; - } - } - var fileId = extractFileId(assetUrl); - var fileVersion = parseInt(extractFileVersion(assetUrl), 10); - if (fileId) { - API.getBundles(fileId) - .then((args2) => { - var {versions} = args2.json; - for (let i = versions.length - 1; i > -1; i--) { - var version = versions[i]; - if (version.version === fileVersion) { - D.fileCreatedAt = version.created_at; - D.fileSize = `${( - version.file.sizeInBytes / 1048576 - ).toFixed(2)} MiB`; - break; - } - } - }) - .catch(() => { + $app.getBundleDateSize(ref) + .then(({createdAt, fileSize}) => { + D.fileCreatedAt = createdAt; + if (fileSize) { + D.fileSize = fileSize; + } else { D.fileSize = 'Error'; - }); - } + } + }) + .catch(() => { + D.fileSize = 'Error'; + }); } }); + $app.methods.getBundleDateSize = async function (ref) { + var assetUrl = ''; + var createdAt = ''; + var fileSize = ''; + for (let i = ref.unityPackages.length - 1; i > -1; i--) { + var unityPackage = ref.unityPackages[i]; + if ( + unityPackage.platform === 'standalonewindows' && + this.compareUnityVersion(unityPackage.unityVersion) + ) { + assetUrl = unityPackage.assetUrl; + break; + } + } + var fileId = extractFileId(assetUrl); + var fileVersion = parseInt(extractFileVersion(assetUrl), 10); + if (fileId) { + var args = await API.getBundles(fileId); + if ( + typeof args.json !== 'undefined' && + typeof args.json.versions !== 'undefined' + ) { + var {versions} = args.json; + for (let i = versions.length - 1; i > -1; i--) { + var version = versions[i]; + if (version.version === fileVersion) { + createdAt = version.created_at; + fileSize = `${( + version.file.sizeInBytes / 1048576 + ).toFixed(2)} MiB`; + break; + } + } + } + } + return {createdAt, fileSize}; + }; + API.$on('FAVORITE', function (args) { var {ref} = args; var D = $app.worldDialog; diff --git a/html/src/index.pug b/html/src/index.pug index c103e6e5..f4b815c7 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -77,23 +77,28 @@ html //- playerList .x-container(v-show="$refs.menu && $refs.menu.activeIndex === 'playerList'") div(style="display:flex;flex-direction:column;height:100%") - div(v-if="currentInstanceWorld.id" style="display:flex") + div(v-if="currentInstanceWorld.ref.id" style="display:flex") el-popover(placement="right" width="500px" trigger="click" style="height:120px") - img.x-link(slot="reference" v-lazy="currentInstanceWorld.thumbnailImageUrl" style="flex:none;width:160px;height:120px;border-radius:4px") - img.x-link(v-lazy="currentInstanceWorld.imageUrl" style="width:500px;height:375px" @click="openExternalLink(currentInstanceWorld.imageUrl)") + img.x-link(slot="reference" v-lazy="currentInstanceWorld.ref.thumbnailImageUrl" style="flex:none;width:160px;height:120px;border-radius:4px") + img.x-link(v-lazy="currentInstanceWorld.ref.imageUrl" style="width:500px;height:375px" @click="openExternalLink(currentInstanceWorld.ref.imageUrl)") div(style="margin-left:10px;display:flex;flex-direction:column;min-width:320px;width:100%") div - span.x-link(@click="showWorldDialog(currentInstanceWorld.id)" style="font-weight:bold;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1") - | #[i.el-icon-s-home(v-show="API.currentUser.$homeLocation && API.currentUser.$homeLocation.worldId === currentInstanceWorld.id" style="margin-right:5px")] {{ currentInstanceWorld.name }} + span.x-link(@click="showWorldDialog(currentInstanceWorld.ref.id)" style="font-weight:bold;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1") + | #[i.el-icon-s-home(v-show="API.currentUser.$homeLocation && API.currentUser.$homeLocation.worldId === currentInstanceWorld.ref.id" style="margin-right:5px")] {{ currentInstanceWorld.ref.name }} div - span.x-link(v-text="currentInstanceWorld.authorName" @click="showUserDialog(currentInstanceWorld.authorId)" style="color:#909399;font-family:monospace") + span.x-link(v-text="currentInstanceWorld.ref.authorName" @click="showUserDialog(currentInstanceWorld.ref.authorId)" style="color:#909399;font-family:monospace") div(style="margin-top:5px") - el-tag(v-if="currentInstanceWorld.$isLabs" type="primary" effect="plain" size="mini" style="margin-right:5px") Labs - el-tag(v-else-if="currentInstanceWorld.releaseStatus === 'public'" type="success" effect="plain" size="mini" style="margin-right:5px") Public - el-tag(v-else-if="currentInstanceWorld.releaseStatus === 'private'" type="danger" effect="plain" size="mini" style="margin-right:5px") Private - el-tag.x-tag-platform-pc(v-if="currentInstanceWorld.$isPC" type="info" effect="plain" size="mini" style="margin-right:5px") PC - el-tag.x-tag-platform-quest(v-if="currentInstanceWorld.$isQuest" type="info" effect="plain" size="mini" style="margin-right:5px") Quest - span.x-link(@click="showLaunchDialog(lastLocation.location)") + el-tag(v-if="currentInstanceWorld.ref.$isLabs" type="primary" effect="plain" size="mini" style="margin-right:5px") Labs + el-tag(v-else-if="currentInstanceWorld.ref.releaseStatus === 'public'" type="success" effect="plain" size="mini" style="margin-right:5px") Public + el-tag(v-else-if="currentInstanceWorld.ref.releaseStatus === 'private'" type="danger" effect="plain" size="mini" style="margin-right:5px") Private + el-tag.x-tag-platform-pc(v-if="currentInstanceWorld.isPC" type="info" effect="plain" size="mini" style="margin-right:5px") PC + el-tag.x-tag-platform-quest(v-if="currentInstanceWorld.isQuest" type="info" effect="plain" size="mini" style="margin-right:5px") Quest + el-tag(type="info" effect="plain" size="mini" v-text="currentInstanceWorld.fileSize" style="margin-right:5px") + el-tag(v-if="currentInstanceWorld.inCache" type="info" effect="plain" size="mini" style="margin-right:5px") + span(v-text="currentInstanceWorld.cacheSize") + | Cache + br + span.x-link(v-if="currentInstanceLocation.instanceName" @click="showLaunchDialog(lastLocation.location)") span \#{{ currentInstanceLocation.instanceName }} {{ currentInstanceLocation.accessType }} span.famfamfam-flags(v-if="currentInstanceLocation.region === 'eu'" class="europeanunion" style="display:inline-block;margin-left:5px") span.famfamfam-flags(v-else-if="currentInstanceLocation.region === 'jp'" class="jp" style="display:inline-block;margin-left:5px") @@ -112,22 +117,21 @@ html span.x-link(v-text="getDisplayNameFromPhotonId(id)" @click="showUserFromPhotonId(id)" style="margin-right:5px") span(v-text="photonLobbyBots.length" style="color:red") |  #[timer(v-if="lastLocation.date" :epoch="lastLocation.date")] - //- el-tag(type="info" effect="plain" size="mini" v-text="worldDialog.fileSize" style="margin-right:5px") div(style="margin-top:5px") - span(v-show="currentInstanceWorld.name !== currentInstanceWorld.description" v-text="currentInstanceWorld.description" style="font-size:12px;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2") + span(v-show="currentInstanceWorld.ref.name !== currentInstanceWorld.ref.description" v-text="currentInstanceWorld.ref.description" style="font-size:12px;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2") div(style="display:flex;flex-direction:column;margin-left:20px") .x-friend-item(style="cursor:default") .detail span.name Capacity - span.extra {{ currentInstanceWorld.capacity | commaNumber }} ({{ currentInstanceWorld.capacity * 2 | commaNumber }}) + span.extra {{ currentInstanceWorld.ref.capacity | commaNumber }} ({{ currentInstanceWorld.ref.capacity * 2 | commaNumber }}) .x-friend-item(style="cursor:default") .detail span.name Last Updated - span.extra {{ currentInstanceWorld.updated_at | formatDate('long') }} + span.extra {{ currentInstanceWorld.fileCreatedAt | formatDate('long') }} .x-friend-item(style="cursor:default") .detail span.name Created - span.extra {{ currentInstanceWorld.created_at | formatDate('long') }} + span.extra {{ currentInstanceWorld.ref.created_at | formatDate('long') }} div.current-instance-table data-tables(v-bind="currentInstanceUserList" @row-click="selectCurrentInstanceRow" style="margin-top:10px;cursor:pointer") el-table-column(label="Avatar" width="60" prop="photo")