removeChatMember method
override
Removes an User from a Chat-group by the authority of the authenticated MyUser.
Implementation
@override
Future<void> removeChatMember(ChatId chatId, UserId userId) async {
Log.debug('removeChatMember($chatId, $userId)', '$runtimeType');
final RxChatImpl? chat = chats[chatId];
final DtoChatMember? member = chat?.members.pagination?.items[userId];
if (chat?.chat.value.isGroup == false) {
// No-op.
return;
}
chat?.members.remove(userId);
try {
try {
await Backoff.run(
() async {
await _graphQlProvider.removeChatMember(chatId, userId);
},
retryIf: (e) => e.isNetworkRelated,
retries: 10,
);
} on RemoveChatMemberException catch (e) {
switch (e.code) {
case RemoveChatMemberErrorCode.artemisUnknown:
rethrow;
case RemoveChatMemberErrorCode.notGroup:
if (member != null) {
chat?.members.put(member);
}
break;
case RemoveChatMemberErrorCode.unknownChat:
await remove(chatId);
break;
}
}
} catch (_) {
if (member != null) {
chat?.members.put(member);
}
rethrow;
}
await onMemberRemoved?.call(chatId, userId);
}