From bde43053d7130367950c0addb372638175d9239c Mon Sep 17 00:00:00 2001 From: Natsumi Date: Wed, 14 Apr 2021 00:58:32 +1200 Subject: [PATCH] Fix clicking avatars in feed --- html/src/app.js | 90 +++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 47 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index 654990ee..a7a3e1f0 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -8160,18 +8160,27 @@ speechSynthesis.getVoices(); if (fileId) { if (API.cachedAvatarNames.has(fileId)) { var { ownerId } = API.cachedAvatarNames.get(fileId); + if (ownerId === D.id) { + this.$message({ + message: 'It\'s personal (own) avatar', + type: 'warning' + }); + return; + } + this.showUserDialog(ownerId); } else { - var args = API.getAvatarImages({fileId: fileId}); - var ownerId = args.json.ownerId; - } - if (ownerId === D.id) { - this.$message({ - message: 'It\'s personal (own) avatar', + API.getAvatarImages({fileId}).then((args) => { + var ownerId = args.json.ownerId; + if (ownerId === D.id) { + this.$message({ + message: 'It\'s personal (own) avatar', type: 'warning' }); - return; + return; + } + this.showUserDialog(ownerId); + }); } - this.showUserDialog(ownerId); } else { this.$message({ message: 'Sorry, the author is unknown', @@ -8741,50 +8750,37 @@ speechSynthesis.getVoices(); }; $app.methods.showAvatarAuthorDialog = function (refUserId, currentAvatarImageUrl) { - var id = extractFileId(currentAvatarImageUrl); - if (id) { - API.call(`file/${id}`).then(({ ownerId }) => { - for (var ref of API.cachedAvatars.values()) { - if (ref.imageUrl === currentAvatarImageUrl) { - this.showAvatarDialog(ref.id); - return; - } + for (var ref of API.cachedAvatars.values()) { + if (ref.imageUrl === currentAvatarImageUrl) { + this.showAvatarDialog(ref.id); + return; + } + } + var fileId = extractFileId(currentAvatarImageUrl); + if (fileId) { + if (API.cachedAvatarNames.has(fileId)) { + var { ownerId } = API.cachedAvatarNames.get(fileId); + if (ownerId === refUserId) { + this.$message({ + message: 'It\'s personal (own) avatar', + type: 'warning' + }); + return; } - var params = { - n: 50, - offset: 0, - sort: 'updated', - order: 'descending', - // user: 'friends', - userId: ownerId, - releaseStatus: 'public' - }; - if (params.userId === API.currentUser.id) { - params.user = 'me'; - params.releaseStatus = 'all'; - } - API.bulk({ - fn: 'getAvatars', - N: -1, - params, - done: () => { - for (var ref2 of API.cachedAvatars.values()) { - if (ref2.imageUrl === currentAvatarImageUrl) { - this.showAvatarDialog(ref2.id); - return; - } - } - if (ownerId === refUserId) { - this.$message({ - message: 'It\'s personal (own) avatar', + this.showUserDialog(ownerId); + } else { + API.getAvatarImages({fileId}).then((args) => { + var ownerId = args.json.ownerId; + if (ownerId === refUserId) { + this.$message({ + message: 'It\'s personal (own) avatar', type: 'warning' }); - return; - } - this.showUserDialog(ownerId); + return; } + this.showUserDialog(ownerId); }); - }); + } } else { this.$message({ message: 'Sorry, the author is unknown',