calcLocalizedBodyFallback method
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(SDNLocalizations 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;
}