From 8eb98a850bc357c09f2a6db47fc8ce94aa89d06c Mon Sep 17 00:00:00 2001 From: Noach Magedman Date: Sun, 26 Nov 2023 14:07:13 +0200 Subject: [PATCH] PATCH: setRoomAvatar saves the new etag immediately I see no reason for us to delay updating room's avatar data for some arbitrary duration (500 ms). Note that unlike with the `users.setAvatar` API patch, we do NOT return the new avatarETag in the `rooms.saveRoomSettings` API response, since that would require too many changes to the code flow and its type-scripting. For now, SAPI will have to re-fetch the room object and hope that there are no race conditions! --- apps/meteor/app/lib/server/functions/setRoomAvatar.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/meteor/app/lib/server/functions/setRoomAvatar.ts b/apps/meteor/app/lib/server/functions/setRoomAvatar.ts index 1da89604de0ee..bd8bded5c8eab 100644 --- a/apps/meteor/app/lib/server/functions/setRoomAvatar.ts +++ b/apps/meteor/app/lib/server/functions/setRoomAvatar.ts @@ -42,9 +42,9 @@ export const setRoomAvatar = async function (rid: string, dataURI: string, user: } const result = await fileStore.insert(file, buffer); + result.etag && (await Rooms.setAvatarData(rid, 'upload', result.etag)); setTimeout(async function () { - result.etag && (await Rooms.setAvatarData(rid, 'upload', result.etag)); await Message.saveSystemMessage('room_changed_avatar', rid, '', user); void api.broadcast('room.avatarUpdate', { _id: rid, avatarETag: result.etag }); }, 500);