Skip to content

Commit

Permalink
PATCH: setRoomAvatar saves the new etag immediately
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
nmagedman committed Nov 26, 2023
1 parent 9bc4a00 commit 8eb98a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion apps/meteor/app/lib/server/functions/setRoomAvatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8eb98a8

Please sign in to comment.