toggleChatMute method
- ChatId id,
- MuteDuration? mute
override
Mutes or unmutes the specified Chat for the authenticated MyUser. Overrides an existing mute even if it's longer.
Implementation
@override
Future<void> toggleChatMute(ChatId id, MuteDuration? mute) async {
Log.debug('toggleChatMute($id, $mute)', '$runtimeType');
final RxChatImpl? chat = chats[id];
final MuteDuration? muted = chat?.chat.value.muted;
final Muting? muting = mute == null
? null
: Muting(duration: mute.forever == true ? null : mute.until);
chat?.chat.update((c) => c?.muted = muting?.toModel());
try {
try {
await _graphQlProvider.toggleChatMute(id, muting);
} on ToggleChatMuteException catch (e) {
switch (e.code) {
case ToggleChatMuteErrorCode.tooShort:
case ToggleChatMuteErrorCode.artemisUnknown:
rethrow;
case ToggleChatMuteErrorCode.unknownChat:
await remove(id);
break;
case ToggleChatMuteErrorCode.monolog:
// No-op.
break;
}
}
} catch (e) {
chat?.chat.update((c) => c?.muted = muted);
rethrow;
}
}