From 79b74e2bbf0d1dbe0a53075b559f9dd6b4a9f21d Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Thu, 25 Nov 2021 09:00:59 +0100 Subject: [PATCH] fix: Remove user avatar --- lib/src/client.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index 0a0aa79b..4ce9629e 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -824,13 +824,17 @@ class Client extends MatrixApi { /// Uploads a new user avatar for this user. Leave file null to remove the /// current avatar. Future setAvatar(MatrixFile? file) async { - final uploadResp = file == null - ? null - : await uploadContent( - file.bytes, - filename: file.name, - contentType: file.mimeType, - ); + if (file == null) { + // We send an empty String to remove the avatar. Sending Null **should** + // work but it doesn't with Synapse. See: + // https://gitlab.com/famedly/company/frontend/famedlysdk/-/issues/254 + return setAvatarUrl(userID!, Uri.parse('')); + } + final uploadResp = await uploadContent( + file.bytes, + filename: file.name, + contentType: file.mimeType, + ); await setAvatarUrl(userID!, uploadResp); return; }