Fix avatar errors

This commit is contained in:
Natsumi
2021-04-22 13:55:47 +12:00
parent 2946c9f6ad
commit 8eb1321ca7
2 changed files with 31 additions and 43 deletions

View File

@@ -2654,17 +2654,6 @@ speechSynthesis.getVoices();
}
});
API.$on('FAVORITE:FRIEND:LIST', function (args) {
for (var json of args.json) {
this.$emit('USER', {
json,
params: {
userId: json.id
}
});
}
});
API.$on('FAVORITE:WORLD:LIST', function (args) {
for (var json of args.json) {
if (json.id === '???') {
@@ -2755,7 +2744,6 @@ speechSynthesis.getVoices();
API.refreshFavoriteItems = function () {
var types = {
// 'friend': [0, 'getFavoriteFriends'],
'world': [0, 'getFavoriteWorlds'],
'avatar': [0, 'getFavoriteAvatars']
};
@@ -3150,26 +3138,6 @@ speechSynthesis.getVoices();
});
};
/*
params: {
n: number,
offset: number
}
*/
API.getFavoriteFriends = function (params) {
return this.call('auth/user/friends/favorite', {
method: 'GET',
params
}).then((json) => {
var args = {
json,
params
};
this.$emit('FAVORITE:FRIEND:LIST', args);
return args;
});
};
/*
params: {
n: number,
@@ -7497,6 +7465,7 @@ speechSynthesis.getVoices();
$avatarInfo: {
ownerId: '',
avatarName: '',
fileCreatedAt: ''
}
};
@@ -8527,12 +8496,13 @@ speechSynthesis.getVoices();
return;
}
D.ref = args.ref;
if (D.fileSize === 'Loading') {
if (D.fileSize === 'Unknown') {
var id = extractFileId(args.ref.assetUrl);
if (id) {
D.fileSize = 'Loading';
this.call(`file/${id}`).then((json) => {
var ref = json.versions[json.versions.length - 1];
D.fileCreatedAt = ref.created_at;
D.ref.created_at = ref.created_at;
D.fileSize = `${(ref.file.sizeInBytes / 1048576).toFixed(2)} MiB`;
});
}
@@ -8564,8 +8534,7 @@ speechSynthesis.getVoices();
var D = this.avatarDialog;
D.id = avatarId;
D.treeData = [];
D.fileCreatedAt = '';
D.fileSize = 'Loading';
D.fileSize = 'Unknown';
D.visible = true;
D.loading = true;
API.getCachedAvatar({
@@ -8575,12 +8544,25 @@ speechSynthesis.getVoices();
D.visible = false;
throw err;
}).then((args) => {
if (D.id === args.ref.id) {
if ((D.visible) && (D.id === args.ref.id)) {
D.loading = false;
D.ref = args.ref;
D.isFavorite = API.cachedFavoritesByObjectId.has(D.ref.id);
if (args.cache) {
if ((args.cache) && (D.ref.authorId === API.currentUser.id)) {
API.getAvatar(args.params);
} else {
var fileId = extractFileId(D.ref.imageUrl);
if ((fileId) && (!D.ref.created_at)) {
if (API.cachedAvatarNames.has(fileId)) {
var avatarInfo = API.cachedAvatarNames.get(fileId);
D.ref.created_at = avatarInfo.fileCreatedAt;
} else {
API.getAvatarImages({fileId}).then((args) => {
var avatarInfo = this.storeAvatarImage(args);
D.ref.created_at = avatarInfo.fileCreatedAt;
});
}
}
}
}
return args;
@@ -10696,6 +10678,9 @@ speechSynthesis.getVoices();
});
$app.methods.storeAvatarImage = function (args) {
var refCreatedAt = args.json.versions[0];
var fileCreatedAt = refCreatedAt.created_at;
var ref = args.json.versions[args.json.versions.length - 1];
var fileId = args.params.fileId;
var avatarName = '';
var imageName = args.json.name;
@@ -10706,7 +10691,8 @@ speechSynthesis.getVoices();
var ownerId = args.json.ownerId;
var avatarInfo = {
ownerId,
avatarName
avatarName,
fileCreatedAt
};
API.cachedAvatarNames.set(fileId, avatarInfo);
return avatarInfo;

View File

@@ -1110,7 +1110,7 @@ html
span(v-if="!scope.data.children" v-text="scope.data.value")
//- dialog: world
el-dialog.x-dialog.x-world-dialog(ref="worldDialog" :visible.sync="worldDialog.visible" :show-close="false" width="600px")
el-dialog.x-dialog.x-world-dialog(ref="worldDialog" :visible.sync="worldDialog.visible" :show-close="false" width="770px")
div(v-loading="worldDialog.loading")
div(style="display:flex")
el-popover(placement="right" width="500px" trigger="click")
@@ -1274,15 +1274,17 @@ html
.x-friend-item(style="cursor:default")
.detail
span.name Last Updated
span.extra {{ avatarDialog.fileCreatedAt | formatDate('YYYY-MM-DD HH24:MI:SS') || '-' }}
span.extra {{ avatarDialog.ref.updated_at | formatDate('YYYY-MM-DD HH24:MI:SS') || '-' }}
.x-friend-item(style="cursor:default")
.detail
span.name Version
span.extra(v-text="avatarDialog.ref.version")
span.extra(v-if="avatarDialog.ref.version !== 0" v-text="avatarDialog.ref.version")
span.extra(v-else) -
.x-friend-item(style="width:100%;cursor:default")
.detail
span.name Platform
span.extra(v-text="avatarDialogPlatform")
span.extra(v-if="avatarDialogPlatform" v-text="avatarDialogPlatform")
span.extra(v-else) -
el-tab-pane(label="JSON")
el-button(type="default" @click="refreshAvatarDialogTreeData()" size="mini" icon="el-icon-refresh" circle)
el-tree(:data="avatarDialog.treeData" style="margin-top:5px;font-size:12px")