Fallback for listing sender names.

Sender names now show up if they are in your contacts, even if they do not have List Number enabled.
If their name can not be obtained then it will show "Unknown#0000" rather than just the nanochat number.

(cherry picked from commit 90775680d8b7b2d95636dd1027e56d48118e55e1)
This commit is contained in:
Evaisa 2025-11-04 00:13:44 +01:00 committed by Tobias Berger
parent fc558e41ea
commit 19722eeec7
No known key found for this signature in database
GPG Key ID: 2D05EFAB764D6A88
2 changed files with 11 additions and 10 deletions

View File

@ -563,24 +563,24 @@ public sealed partial class NanoChatUiFragment : BoxContainer
string? senderName = null;
if (isGroupChat && !isOwnMessage)
{
// Try to get sender name from contacts first, then recipients
if (_contacts != null)
// Funky Station - Try to get sender name from contacts first, then recipients
if (_recipients.TryGetValue(message.SenderId, out var senderRecipient))
{
senderName = senderRecipient.Name;
}
// If not in recipients, try contacts list (station-wide directory)
if (senderName == null && _contacts != null)
{
var contact = _contacts.FirstOrDefault(c => c.Number == message.SenderId);
if (contact.Number != 0)
senderName = contact.Name;
}
// If not found in contacts, try recipients
if (senderName == null && _recipients.TryGetValue(message.SenderId, out var senderRecipient))
{
senderName = senderRecipient.Name;
}
// Fallback to number if name not found
// Fallback to "Unknown" with number if name not found
if (senderName == null)
{
senderName = $"#{message.SenderId:D4}";
senderName = $"{Loc.GetString("nano-chat-unknown-sender")}#{message.SenderId:D4}"; // Funky Station
}
}

View File

@ -36,3 +36,4 @@ nano-chat-emoji-search = Search emojis...
# Department sorting
nano-chat-other-department = Other
nano-chat-unknown-sender = Unknown