send method

Future<void> send(
  1. Message message, {
  2. ChatSilentNotification? notification,
  3. VerifyToSendMessage? verifyToSend,
  4. OnDeniedToSendMessage? onDeniedToSend,
})

Implementation

Future<void> send(
  Message message, {
  ChatSilentNotification? notification,
  VerifyToSendMessage? verifyToSend,
  OnDeniedToSendMessage? onDeniedToSend,
}) async {
  if (room.isLocal) {
    final global = await RoomManager.i.createOrGetRoom(
      room,
      notification: const ChatSilentNotification(),
    );
    if (global.isEmpty) return;
    room = global;
    notify();
  }

  final msg = message.copyWith(roomId: roomId, replyId: replyMsg?.id);

  _pendingSendIds.add(msg.id);
  put(msg);

  final sent = await RoomManager.i.createMessage(
    msg,
    notification: notification ?? const ChatSilentNotification(),
    verifyToSend: verifyToSend,
    onDeniedToSend: onDeniedToSend,
  );

  _pendingSendIds.remove(sent.id);
  put(sent);
}