mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 22:33:50 +02:00
Avatar info in feed
This commit is contained in:
@@ -845,6 +845,51 @@ speechSynthesis.getVoices();
|
||||
}
|
||||
});
|
||||
|
||||
Vue.component('avatar-info', {
|
||||
template: '<div @click="confirm" style="cursor:pointer;width:fit-content;display:inline-block;vertical-align:top"><span style="display:inline-block;margin-right:5px">{{ avatarName }}</span><span :class="color">{{ avatarType }}</span></div>',
|
||||
props: {
|
||||
imageurl: String,
|
||||
userid: String
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
avatarName: this.avatarName,
|
||||
avatarType: this.avatarType,
|
||||
color: this.color
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async parse() {
|
||||
this.avatarName = '';
|
||||
this.avatarType = '';
|
||||
this.color = '';
|
||||
var avatarInfo = await $app.getAvatarName(this.imageurl);
|
||||
this.avatarName = avatarInfo.avatarName;
|
||||
if ((typeof this.userid === 'undefined') || (!avatarInfo.ownerId)) {
|
||||
this.color = 'avatar-info-unknown';
|
||||
this.avatarType = '(unknown)';
|
||||
} else if (avatarInfo.ownerId === this.userid) {
|
||||
this.color = 'avatar-info-own';
|
||||
this.avatarType = '(own)';
|
||||
} else {
|
||||
this.color = 'avatar-info-public';
|
||||
this.avatarType = '(public)';
|
||||
}
|
||||
},
|
||||
confirm() {
|
||||
$app.showAvatarAuthorDialog(this.userid, this.imageurl);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
imageurl() {
|
||||
this.parse();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.parse();
|
||||
}
|
||||
});
|
||||
|
||||
// API: User
|
||||
|
||||
// changeUserName: PUT users/${userId} {displayName: string, currentPassword: string}
|
||||
@@ -8229,7 +8274,6 @@ speechSynthesis.getVoices();
|
||||
}
|
||||
D.ref = ref;
|
||||
$app.applyUserDialogLocation();
|
||||
$app.getAvatarName(ref.currentAvatarImageUrl);
|
||||
});
|
||||
|
||||
API.$on('WORLD', function (args) {
|
||||
@@ -8459,7 +8503,6 @@ speechSynthesis.getVoices();
|
||||
if (args.cache) {
|
||||
API.getUser(args.params);
|
||||
}
|
||||
this.getAvatarName(args.ref.currentAvatarImageUrl);
|
||||
var L = API.parseLocation(D.ref.location);
|
||||
if ((L.worldId) &&
|
||||
(this.lastLocation.location !== L.tag)) {
|
||||
@@ -8822,7 +8865,6 @@ speechSynthesis.getVoices();
|
||||
API.getFriendStatus({
|
||||
userId: D.id
|
||||
});
|
||||
this.getAvatarName(args.ref.currentAvatarImageUrl);
|
||||
var L = API.parseLocation(D.ref.location);
|
||||
if ((L.worldId) &&
|
||||
(this.lastLocation.location !== L.tag)) {
|
||||
@@ -8882,7 +8924,7 @@ speechSynthesis.getVoices();
|
||||
});
|
||||
} else if (command === 'Show Avatar Author') {
|
||||
var { currentAvatarImageUrl } = D.ref;
|
||||
this.showAvatarAuthorDialog(D.id, currentAvatarImageUrl)
|
||||
this.showAvatarAuthorDialog(D.id, currentAvatarImageUrl);
|
||||
} else if (command === 'Show Fallback Avatar Details') {
|
||||
var { fallbackAvatar } = D.ref;
|
||||
if (fallbackAvatar) {
|
||||
@@ -12046,30 +12088,19 @@ speechSynthesis.getVoices();
|
||||
|
||||
API.cachedAvatarNames = new Map();
|
||||
|
||||
$app.methods.getAvatarName = function (imageUrl) {
|
||||
var D = this.userDialog;
|
||||
D.$avatarInfo = {
|
||||
ownerId: '',
|
||||
avatarName: '-'
|
||||
};
|
||||
if (!D.visible) {
|
||||
return;
|
||||
}
|
||||
$app.methods.getAvatarName = async function (imageUrl) {
|
||||
var fileId = extractFileId(imageUrl);
|
||||
if (!fileId) {
|
||||
return;
|
||||
return {
|
||||
ownerId: '',
|
||||
avatarName: '-'
|
||||
};
|
||||
}
|
||||
if (API.cachedAvatarNames.has(fileId)) {
|
||||
D.$avatarInfo = API.cachedAvatarNames.get(fileId);
|
||||
return;
|
||||
return API.cachedAvatarNames.get(fileId);
|
||||
}
|
||||
var params = {
|
||||
fileId
|
||||
};
|
||||
API.getAvatarImages(params).then((args) => {
|
||||
var avatarInfo = this.storeAvatarImage(args);
|
||||
this.userDialog.$avatarInfo = avatarInfo;
|
||||
});
|
||||
var args = await API.getAvatarImages({fileId});
|
||||
return this.storeAvatarImage(args);
|
||||
};
|
||||
|
||||
$app.data.discordNamesDialogVisible = false;
|
||||
|
||||
Reference in New Issue
Block a user