removeMessage method
Remove a message
from this channelState.
Implementation
void removeMessage(Message message) async {
await _channel._client.chatPersistenceClient?.deleteMessageById(message.id);
final parentId = message.parentId;
// i.e. it's a thread message, Remove it
if (parentId != null) {
final newThreads = {...threads};
// Early return in case the thread is not available
if (!newThreads.containsKey(parentId)) return;
_threads = newThreads
..update(
parentId,
(messages) => messages..removeWhere((e) => e.id == message.id),
);
// Early return if the thread message is not shown in channel.
if (message.showInChannel == false) return;
}
// Remove regular message, thread message shown in channel
final allMessages = [...messages];
_channelState = _channelState.copyWith(
messages: allMessages..removeWhere((e) => e.id == message.id),
);
}