From 7c95c23ec8cf2f4c0fc3c986fbf243a52bf930e7 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Thu, 22 Sep 2022 04:43:17 +1200 Subject: [PATCH] Fix launching with shortName --- html/src/app.js | 72 +++++++++++++++++++++++++++++++++++----------- html/src/index.pug | 3 +- 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index 86004eea..40369cec 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -453,6 +453,12 @@ speechSynthesis.getVoices(); ) { this.expireNotification(init.inviteId); } + if ( + status === 403 && + endpoint.startsWith('invite/myself/to/') + ) { + throw new Error(`403: ${data.error.message} ${endpoint}`); + } if (data && data.error === Object(data.error)) { this.$throw( data.error.status_code || status, @@ -2005,13 +2011,21 @@ speechSynthesis.getVoices(); method: 'POST', params } - ).then((json) => { - var args = { - json, - params - }; - return args; - }); + ) + .then((json) => { + var args = { + json, + params + }; + return args; + }) + .catch((err) => { + $app.$message({ + message: "you're not allowed to access this instance.", + type: 'error' + }); + throw err; + }); }; API.$on('INSTANCE', function (args) { @@ -12947,7 +12961,11 @@ speechSynthesis.getVoices(); ); }; - $app.methods.promptSetAvatarRemoteDatabase = function () { + $app.methods.promptSetAvatarRemoteDatabase = function (newUrl) { + var inputValue = this.avatarRemoteDatabaseProvider; + if (newUrl) { + inputValue = newUrl; + } this.$prompt( 'Enter avatar database provider URL', 'Avatar Database Provider', @@ -12955,16 +12973,24 @@ speechSynthesis.getVoices(); distinguishCancelAndClose: true, confirmButtonText: 'OK', cancelButtonText: 'Cancel', - inputValue: this.avatarRemoteDatabaseProvider, - inputPattern: /\S+/, + inputValue, inputErrorMessage: 'Valid URL is required', callback: (action, instance) => { - if (action === 'confirm' && instance.inputValue) { + if (action === 'confirm') { this.avatarRemoteDatabaseProvider = instance.inputValue; configRepository.setString( 'VRCX_avatarRemoteDatabaseProvider', this.avatarRemoteDatabaseProvider ); + if (this.avatarRemoteDatabaseProvider) { + this.avatarRemoteDatabase = true; + } else { + this.avatarRemoteDatabase = false; + } + configRepository.setBool( + 'VRCX_avatarRemoteDatabase', + this.avatarRemoteDatabase + ); } } } @@ -13230,8 +13256,6 @@ speechSynthesis.getVoices(); $app.methods.showUserDialog = function (userId) { this.$nextTick(() => adjustDialogZ(this.$refs.userDialog.$el)); var D = this.userDialog; - D.currentAvatarThumbnailImageUrl = ''; - D.userIcon = ''; D.id = userId; D.treeData = []; D.memo = ''; @@ -15762,17 +15786,24 @@ speechSynthesis.getVoices(); }); API.$on('INSTANCE:SHORTNAME', function (args) { - if (!args.params || !args.json || !args.json.shortName) { + if (!args.json) { return; } var shortName = args.json.shortName; - var location = `${args.params.worldId}:${args.params.instanceId}`; + var location = `${args.instance.worldId}:${args.instance.instanceId}`; + var L = this.parseLocation(location); + if (!shortName) { + if (location === $app.launchDialog.tag && args.json.secureName) { + $app.launchDialog.location = `${L.worldId}:${L.instanceId}&shortName=${args.json.secureName}`; + } + return; + } if (location === $app.launchDialog.tag) { - var L = this.parseLocation(location); L.shortName = shortName; $app.launchDialog.shortName = shortName; $app.launchDialog.shortUrl = `https://vrch.at/${shortName}`; $app.launchDialog.url = $app.getLaunchURL(L); + $app.launchDialog.location = `${L.worldId}:${L.instanceId}&shortName=${shortName}`; } if (location === $app.newInstanceDialog.location) { $app.newInstanceDialog.shortName = shortName; @@ -15806,7 +15837,9 @@ speechSynthesis.getVoices(); D.shortName = shortName; D.shortUrl = `https://vrch.at/${shortName}`; } - if (L.instanceId) { + if (shortName && L.instanceId) { + D.location = `${L.worldId}:${L.instanceId}&shortName=${shortName}`; + } else if (L.instanceId) { D.location = `${L.worldId}:${L.instanceId}`; } else { D.location = L.worldId; @@ -19427,6 +19460,11 @@ speechSynthesis.getVoices(); case 'user': this.showUserDialog(commandArg); break; + case 'addavatardb': + this.promptSetAvatarRemoteDatabase( + input.replace('addavatardb/', '') + ); + break; } }; diff --git a/html/src/index.pug b/html/src/index.pug index 6fed2fe4..7b4b45fe 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -489,6 +489,7 @@ html template(v-once) .avatar img(v-if="avatar.thumbnailImageUrl" v-lazy="avatar.thumbnailImageUrl") + img(v-else-if="avatar.imageUrl" v-lazy="avatar.imageUrl") .detail span.name(v-text="avatar.name") span.extra(v-text="avatar.releaseStatus" v-if="avatar.releaseStatus === 'public'" style="color: #67c23a;") @@ -1267,7 +1268,7 @@ html span.name Enable el-switch(v-model="avatarRemoteDatabase" @change="saveOpenVROption") div.options-container-item - el-button(size="small" icon="el-icon-user-solid" @click="promptSetAvatarRemoteDatabase" :disabled="!avatarRemoteDatabase") Avatar Database Provider + el-button(size="small" icon="el-icon-user-solid" @click="promptSetAvatarRemoteDatabase('')" :disabled="!avatarRemoteDatabase") Avatar Database Provider div.options-container span.header YouTube API div.options-container-item