Check for valid avatar image url

This commit is contained in:
Natsumi
2021-04-05 06:03:39 +12:00
parent 656cac6843
commit 90ff269815
2 changed files with 8 additions and 5 deletions

View File

@@ -10387,10 +10387,17 @@ speechSynthesis.getVoices();
$app.methods.getAvatarName = function (args) { $app.methods.getAvatarName = function (args) {
var D = this.userDialog; var D = this.userDialog;
D.$avatarInfo = {
id: '',
name: '-'
};
if (!D.visible) { if (!D.visible) {
return; return;
} }
var imageUrl = D.ref.currentAvatarImageUrl; var imageUrl = D.ref.currentAvatarImageUrl;
if (imageUrl.substring(0, 41) !== 'https://api.vrchat.cloud/api/1/file/file_') {
return;
}
var url = new URL(imageUrl); var url = new URL(imageUrl);
var pathArray = url.pathname.split('/'); var pathArray = url.pathname.split('/');
var fileId = pathArray[4]; var fileId = pathArray[4];
@@ -10398,10 +10405,6 @@ speechSynthesis.getVoices();
D.$avatarInfo = API.cachedAvatarNames.get(fileId); D.$avatarInfo = API.cachedAvatarNames.get(fileId);
return; return;
} }
D.$avatarInfo = {
id: '',
name: ''
};
var params = { var params = {
fileId fileId
}; };

View File

@@ -1020,7 +1020,7 @@ html
.extra(@click="userDialogCommand('Show Avatar Details')" style="cursor:pointer;width:fit-content") .extra(@click="userDialogCommand('Show Avatar Details')" style="cursor:pointer;width:fit-content")
span(v-text="userDialog.$avatarInfo.name" style="display:inline-block;margin-right:5px") span(v-text="userDialog.$avatarInfo.name" style="display:inline-block;margin-right:5px")
span(v-if="userDialog.$avatarInfo.id === userDialog.id" style="display:inline-block;color:#E6A23C" ) (own) span(v-if="userDialog.$avatarInfo.id === userDialog.id" style="display:inline-block;color:#E6A23C" ) (own)
span(v-else-if="userDialog.$avatarInfo.name" style="display:inline-block;color:#67C23A") (public) span(v-else-if="userDialog.$avatarInfo.name && userDialog.$avatarInfo.id" style="display:inline-block;color:#67C23A") (public)
.x-friend-item(style="width:100%;cursor:default") .x-friend-item(style="width:100%;cursor:default")
.detail .detail
span.name Bio span.name Bio