calcLocalizedBodyFallback method

String calcLocalizedBodyFallback(
  1. MatrixLocalizations i18n, {
  2. bool withSenderNamePrefix = false,
  3. bool hideReply = false,
  4. bool hideEdit = false,
  5. bool plaintextBody = false,
  6. bool removeMarkdown = false,
})

Works similar to calcLocalizedBody() but does not wait for the sender user to be fetched. If it is not in the cache it will just use the fallback and display the localpart of the MXID according to the values of formatLocalpart and mxidLocalPartFallback in the Client class.

Implementation

String calcLocalizedBodyFallback(MatrixLocalizations i18n,
    {bool withSenderNamePrefix = false,
    bool hideReply = false,
    bool hideEdit = false,
    bool plaintextBody = false,
    bool removeMarkdown = false}) {
  if (redacted) {
    return i18n.removedBy(this);
  }

  final body = calcUnlocalizedBody(
    hideReply: hideReply,
    hideEdit: hideEdit,
    plaintextBody: plaintextBody,
    removeMarkdown: removeMarkdown,
  );

  final callback = EventLocalizations.localizationsMap[type];
  var localizedBody = i18n.unknownEvent(type);
  if (callback != null) {
    localizedBody = callback(this, i18n, body);
  }

  // Add the sender name prefix
  if (withSenderNamePrefix &&
      type == EventTypes.Message &&
      textOnlyMessageTypes.contains(messageType)) {
    final senderNameOrYou = senderId == room.client.userID
        ? i18n.you
        : senderFromMemoryOrFallback.calcDisplayname(i18n: i18n);
    localizedBody = '$senderNameOrYou: $localizedBody';
  }

  return localizedBody;
}