updateMessage method

  1. @override
Future<bool> updateMessage(
  1. String roomId,
  2. String msgId,
  3. Map<String, dynamic> value, {
  4. Map<String, dynamic> roomValues = const {},
  5. ChatSilentNotification? notification,
})
override

Implementation

@override
Future<bool> updateMessage(
  String roomId,
  String msgId,
  Map<String, dynamic> value, {
  Map<String, dynamic> roomValues = const {},
  ChatSilentNotification? notification,
}) async {
  if (me.isEmpty) return false;
  try {
    await RetryHelper.run(
      operation: () {
        return messageDelegate.update(
          roomId,
          msgId,
          n.normalize(value, n.message),
        );
      },
    );
    if (roomValues.isNotEmpty) {
      await RetryHelper.run(
        operation: () {
          return roomDelegate.update(roomId, n.normalize(roomValues, n.room));
        },
      );
    }

    if (notification != null) {
      final msg = managerOrNull(roomId)?.mappedMessages[msgId];
      if (msg != null) await sendNotification(msg, notification);
    }

    return true;
  } catch (e, st) {
    errorReporter.report(
      e,
      stackTrace: st,
      source: 'MessageMixin.updateMessage',
      context: {'roomId': roomId, 'msgId': msgId},
    );
    return false;
  }
}