Fix clicking avatars in feed

This commit is contained in:
Natsumi
2021-04-14 00:58:32 +12:00
parent c8c85c50f2
commit bde43053d7
+28 -32
View File
@@ -8160,10 +8160,6 @@ speechSynthesis.getVoices();
if (fileId) { if (fileId) {
if (API.cachedAvatarNames.has(fileId)) { if (API.cachedAvatarNames.has(fileId)) {
var { ownerId } = API.cachedAvatarNames.get(fileId); var { ownerId } = API.cachedAvatarNames.get(fileId);
} else {
var args = API.getAvatarImages({fileId: fileId});
var ownerId = args.json.ownerId;
}
if (ownerId === D.id) { if (ownerId === D.id) {
this.$message({ this.$message({
message: 'It\'s personal (own) avatar', message: 'It\'s personal (own) avatar',
@@ -8172,6 +8168,19 @@ speechSynthesis.getVoices();
return; return;
} }
this.showUserDialog(ownerId); this.showUserDialog(ownerId);
} else {
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;
}
this.showUserDialog(ownerId);
});
}
} else { } else {
this.$message({ this.$message({
message: 'Sorry, the author is unknown', message: 'Sorry, the author is unknown',
@@ -8741,39 +8750,16 @@ speechSynthesis.getVoices();
}; };
$app.methods.showAvatarAuthorDialog = function (refUserId, currentAvatarImageUrl) { $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()) { for (var ref of API.cachedAvatars.values()) {
if (ref.imageUrl === currentAvatarImageUrl) { if (ref.imageUrl === currentAvatarImageUrl) {
this.showAvatarDialog(ref.id); this.showAvatarDialog(ref.id);
return; return;
} }
} }
var params = { var fileId = extractFileId(currentAvatarImageUrl);
n: 50, if (fileId) {
offset: 0, if (API.cachedAvatarNames.has(fileId)) {
sort: 'updated', var { ownerId } = API.cachedAvatarNames.get(fileId);
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) { if (ownerId === refUserId) {
this.$message({ this.$message({
message: 'It\'s personal (own) avatar', message: 'It\'s personal (own) avatar',
@@ -8782,9 +8768,19 @@ speechSynthesis.getVoices();
return; return;
} }
this.showUserDialog(ownerId); 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);
}); });
}); }
} else { } else {
this.$message({ this.$message({
message: 'Sorry, the author is unknown', message: 'Sorry, the author is unknown',