From 024189a2f293d5f05cabc4b81026e62d6fa7711b Mon Sep 17 00:00:00 2001 From: vjrj <vjrj@comunes.org> Date: Sat, 27 May 2023 09:42:39 +0200 Subject: [PATCH] Humanize contact remove dup and add opt key --- lib/ui/ui_helpers.dart | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/ui/ui_helpers.dart b/lib/ui/ui_helpers.dart index 30878cd8..ec6eab2d 100644 --- a/lib/ui/ui_helpers.dart +++ b/lib/ui/ui_helpers.dart @@ -78,21 +78,14 @@ String humanizeFromToPubKey(String publicAddress, String address) { } } -String humanizeContact(String publicAddress, Contact contact) { - final bool hasName = contact.name?.isNotEmpty ?? false; - final bool hasNick = contact.nick?.isNotEmpty ?? false; - +String humanizeContact(String publicAddress, Contact contact, + [bool addKey = false]) { if (contact.pubKey == publicAddress) { return tr('your_wallet'); } else { - if (hasName && hasNick) - return '${contact.name} (${contact.nick})'; - else if (hasNick) - return contact.nick!; - else if (hasName) - return contact.name!; - else - return humanizePubKey(contact.pubKey); + return addKey + ? '${contact.title} (${humanizePubKey(contact.pubKey)})' + : contact.title; } } -- GitLab