addMembers method
Adds the Users identified by the provided UserIds to this chat.
Implementation
Future<void> addMembers(List<UserId> ids) async {
status.value = RxStatus.loading();
pop?.call();
try {
final Iterable<Future> futures = ids.map(
(userId) => _chatService
.addChatMember(chatId, userId)
.onError<AddChatMemberException>((_, __) async {
final FutureOr<RxUser?> userOrFuture = _userService.get(userId);
final User? user =
(userOrFuture is RxUser? ? userOrFuture : await userOrFuture)
?.user
.value;
if (user != null) {
MessagePopup.error(
'err_blocked_by'.l10nfmt({
'user': '${user.name ?? user.num}',
}),
);
}
}, test: (e) => e.code == AddChatMemberErrorCode.blocked),
);
await Future.wait(futures);
} on AddChatMemberException catch (e) {
MessagePopup.error(e);
} catch (e) {
MessagePopup.error(e);
rethrow;
} finally {
status.value = RxStatus.empty();
}
}