addMessage method
void
addMessage(
- ChatMessage message
Add a Message
to messages
Implementation
void addMessage(ChatMessage message) {
final i = state.messages.indexWhere((e) => e.id == message.id);
if (i < 0) {
emit(state.copyWith(messages: [message, ...state.messages]));
} else {
final messages = state.messages.toList();
messages.removeAt(i);
messages.insert(i, message);
emit(state.copyWith(messages: messages));
}
// Mark message and reactions as seen
// if (message.roomId != null &&
// message.id != null &&
// message.isSeenByMe != true) {
// markMessagesAsSeen(messageIds: [message.id!], roomId: message.roomId!);
// final unseenReactionIds = message.reactions?.unseenMessageIds;
// if (unseenReactionIds.isNotNullOrEmpty) {
// markMessagesAsSeen(
// messageIds: unseenReactionIds!,
// roomId: message.roomId!,
// );
// }
// }
}