decline method
- ChatId chatId
Declines an OngoingCall identified by the given chatId.
Implementation
Future<void> decline(ChatId chatId) async {
Log.debug('decline($chatId)', '$runtimeType');
final Rx<OngoingCall>? call = _callRepository[chatId];
if (call != null) {
// Closing the popup window will kill the pending requests, so it's
// required to await the decline.
if (WebUtils.isPopup) {
await _callRepository.decline(chatId);
// First, try to mark the `Chat` this call is taking place it as read.
await _maybeMarkAsRead(chatId);
// Setting `OngoingCallState` to `ended` will make `PopupCallController`
// to close itself, thus this should be done only after every mutation
// occurs.
call.value.state.value = OngoingCallState.ended;
call.value.dispose();
} else {
call.value.state.value = OngoingCallState.ended;
call.value.dispose();
await _callRepository.decline(chatId);
// Try to mark the `Chat` this call is taking place it as read.
await _maybeMarkAsRead(chatId);
}
}
}