From eb5bc96a3c22c88e2cb1dcda17990b9695c4ae40 Mon Sep 17 00:00:00 2001 From: Islam <2553451+qalandarov@users.noreply.github.com> Date: Fri, 26 Sep 2025 10:13:18 +0100 Subject: [PATCH] Unify the usages of `splitSuffix()` (#683) --- bitchat/Views/GeohashPeopleList.swift | 15 +-------------- bitchat/Views/MeshPeerList.swift | 15 +-------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/bitchat/Views/GeohashPeopleList.swift b/bitchat/Views/GeohashPeopleList.swift index db7c3aa8..098bc99e 100644 --- a/bitchat/Views/GeohashPeopleList.swift +++ b/bitchat/Views/GeohashPeopleList.swift @@ -64,7 +64,7 @@ struct GeohashPeopleList: View { let rowColor: Color = isMe ? .orange : assignedColor Image(systemName: icon).font(.bitchatSystem(size: 12)).foregroundColor(rowColor) - let (base, suffix) = splitSuffix(from: person.displayName) + let (base, suffix) = person.displayName.splitSuffix() HStack(spacing: 0) { Text(base) .font(.bitchatSystem(size: 14, design: .monospaced)) @@ -129,16 +129,3 @@ struct GeohashPeopleList: View { } } } - -// Helper to split a trailing #abcd suffix -private func splitSuffix(from name: String) -> (String, String) { - guard name.count >= 5 else { return (name, "") } - let suffix = String(name.suffix(5)) - if suffix.first == "#", suffix.dropFirst().allSatisfy({ c in - ("0"..."9").contains(String(c)) || ("a"..."f").contains(String(c)) || ("A"..."F").contains(String(c)) - }) { - let base = String(name.dropLast(5)) - return (base, suffix) - } - return (name, "") -} diff --git a/bitchat/Views/MeshPeerList.swift b/bitchat/Views/MeshPeerList.swift index 94390c7f..0dbd4089 100644 --- a/bitchat/Views/MeshPeerList.swift +++ b/bitchat/Views/MeshPeerList.swift @@ -82,7 +82,7 @@ struct MeshPeerList: View { } let displayName = isMe ? viewModel.nickname : peer.nickname - let (base, suffix) = splitSuffix(from: displayName) + let (base, suffix) = displayName.splitSuffix() HStack(spacing: 0) { Text(base) .font(.bitchatSystem(size: 14, design: .monospaced)) @@ -166,16 +166,3 @@ struct MeshPeerList: View { } } } - -// Helper to split a trailing #abcd suffix -private func splitSuffix(from name: String) -> (String, String) { - guard name.count >= 5 else { return (name, "") } - let suffix = String(name.suffix(5)) - if suffix.first == "#", suffix.dropFirst().allSatisfy({ c in - ("0"..."9").contains(String(c)) || ("a"..."f").contains(String(c)) || ("A"..."F").contains(String(c)) - }) { - let base = String(name.dropLast(5)) - return (base, suffix) - } - return (name, "") -}