Unify the usages of splitSuffix() (#683)

This commit is contained in:
Islam 2025-09-26 10:13:18 +01:00 committed by GitHub
parent d01538a2ea
commit eb5bc96a3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 28 deletions

View File

@ -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, "")
}

View File

@ -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, "")
}