Fix launching with shortName

This commit is contained in:
Natsumi
2022-09-22 04:43:17 +12:00
parent 2325969a98
commit 7c95c23ec8
2 changed files with 57 additions and 18 deletions

View File

@@ -453,6 +453,12 @@ speechSynthesis.getVoices();
) { ) {
this.expireNotification(init.inviteId); 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)) { if (data && data.error === Object(data.error)) {
this.$throw( this.$throw(
data.error.status_code || status, data.error.status_code || status,
@@ -2005,13 +2011,21 @@ speechSynthesis.getVoices();
method: 'POST', method: 'POST',
params params
} }
).then((json) => { )
var args = { .then((json) => {
json, var args = {
params json,
}; params
return args; };
}); return args;
})
.catch((err) => {
$app.$message({
message: "you're not allowed to access this instance.",
type: 'error'
});
throw err;
});
}; };
API.$on('INSTANCE', function (args) { 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( this.$prompt(
'Enter avatar database provider URL', 'Enter avatar database provider URL',
'Avatar Database Provider', 'Avatar Database Provider',
@@ -12955,16 +12973,24 @@ speechSynthesis.getVoices();
distinguishCancelAndClose: true, distinguishCancelAndClose: true,
confirmButtonText: 'OK', confirmButtonText: 'OK',
cancelButtonText: 'Cancel', cancelButtonText: 'Cancel',
inputValue: this.avatarRemoteDatabaseProvider, inputValue,
inputPattern: /\S+/,
inputErrorMessage: 'Valid URL is required', inputErrorMessage: 'Valid URL is required',
callback: (action, instance) => { callback: (action, instance) => {
if (action === 'confirm' && instance.inputValue) { if (action === 'confirm') {
this.avatarRemoteDatabaseProvider = instance.inputValue; this.avatarRemoteDatabaseProvider = instance.inputValue;
configRepository.setString( configRepository.setString(
'VRCX_avatarRemoteDatabaseProvider', 'VRCX_avatarRemoteDatabaseProvider',
this.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) { $app.methods.showUserDialog = function (userId) {
this.$nextTick(() => adjustDialogZ(this.$refs.userDialog.$el)); this.$nextTick(() => adjustDialogZ(this.$refs.userDialog.$el));
var D = this.userDialog; var D = this.userDialog;
D.currentAvatarThumbnailImageUrl = '';
D.userIcon = '';
D.id = userId; D.id = userId;
D.treeData = []; D.treeData = [];
D.memo = ''; D.memo = '';
@@ -15762,17 +15786,24 @@ speechSynthesis.getVoices();
}); });
API.$on('INSTANCE:SHORTNAME', function (args) { API.$on('INSTANCE:SHORTNAME', function (args) {
if (!args.params || !args.json || !args.json.shortName) { if (!args.json) {
return; return;
} }
var shortName = args.json.shortName; 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) { if (location === $app.launchDialog.tag) {
var L = this.parseLocation(location);
L.shortName = shortName; L.shortName = shortName;
$app.launchDialog.shortName = shortName; $app.launchDialog.shortName = shortName;
$app.launchDialog.shortUrl = `https://vrch.at/${shortName}`; $app.launchDialog.shortUrl = `https://vrch.at/${shortName}`;
$app.launchDialog.url = $app.getLaunchURL(L); $app.launchDialog.url = $app.getLaunchURL(L);
$app.launchDialog.location = `${L.worldId}:${L.instanceId}&shortName=${shortName}`;
} }
if (location === $app.newInstanceDialog.location) { if (location === $app.newInstanceDialog.location) {
$app.newInstanceDialog.shortName = shortName; $app.newInstanceDialog.shortName = shortName;
@@ -15806,7 +15837,9 @@ speechSynthesis.getVoices();
D.shortName = shortName; D.shortName = shortName;
D.shortUrl = `https://vrch.at/${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}`; D.location = `${L.worldId}:${L.instanceId}`;
} else { } else {
D.location = L.worldId; D.location = L.worldId;
@@ -19427,6 +19460,11 @@ speechSynthesis.getVoices();
case 'user': case 'user':
this.showUserDialog(commandArg); this.showUserDialog(commandArg);
break; break;
case 'addavatardb':
this.promptSetAvatarRemoteDatabase(
input.replace('addavatardb/', '')
);
break;
} }
}; };

View File

@@ -489,6 +489,7 @@ html
template(v-once) template(v-once)
.avatar .avatar
img(v-if="avatar.thumbnailImageUrl" v-lazy="avatar.thumbnailImageUrl") img(v-if="avatar.thumbnailImageUrl" v-lazy="avatar.thumbnailImageUrl")
img(v-else-if="avatar.imageUrl" v-lazy="avatar.imageUrl")
.detail .detail
span.name(v-text="avatar.name") span.name(v-text="avatar.name")
span.extra(v-text="avatar.releaseStatus" v-if="avatar.releaseStatus === 'public'" style="color: #67c23a;") span.extra(v-text="avatar.releaseStatus" v-if="avatar.releaseStatus === 'public'" style="color: #67c23a;")
@@ -1267,7 +1268,7 @@ html
span.name Enable span.name Enable
el-switch(v-model="avatarRemoteDatabase" @change="saveOpenVROption") el-switch(v-model="avatarRemoteDatabase" @change="saveOpenVROption")
div.options-container-item 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 div.options-container
span.header YouTube API span.header YouTube API
div.options-container-item div.options-container-item