deleteChatForward method
- ChatForward forward
override
Deletes the specified ChatForward posted by the authenticated MyUser.
Implementation
@override
Future<void> deleteChatForward(ChatForward forward) async {
Log.debug('deleteChatForward($forward)', '$runtimeType');
final RxChatImpl? chat = chats[forward.chatId];
if (forward.status.value != SendingStatus.sent) {
chat?.remove(forward.id);
} else {
final Rx<ChatItem>? item = chat?.messages.firstWhereOrNull(
(e) => e.value.id == forward.id,
);
if (item != null) {
chat?.messages.remove(item);
}
try {
await _graphQlProvider.deleteChatForward(forward.id);
if (item != null) {
chat?.remove(item.value.id);
}
} catch (_) {
if (item != null) {
chat?.messages.insertAfter(
item,
(e) => item.value.at.compareTo(e.value.at) == 1,
);
chat?.updateReads();
}
rethrow;
}
}
}