From 5b5adf2e2ee0a1303c71e9161328baeaa07e2ed3 Mon Sep 17 00:00:00 2001 From: Taksh Date: Sat, 1 Aug 2026 14:08:13 +0300 Subject: [PATCH] feat: add PeopleNameFilter for people-sheet search Pure case-insensitive display-name match so mesh, geohash, bridge, and group lists can share one query without duplicating trim/empty rules. --- bitchat/Utils/PeopleNameFilter.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 bitchat/Utils/PeopleNameFilter.swift diff --git a/bitchat/Utils/PeopleNameFilter.swift b/bitchat/Utils/PeopleNameFilter.swift new file mode 100644 index 00000000..3e3fafdd --- /dev/null +++ b/bitchat/Utils/PeopleNameFilter.swift @@ -0,0 +1,19 @@ +// +// PeopleNameFilter.swift +// bitchat +// +// This is free and unencumbered software released into the public domain. +// For more information, see +// + +import Foundation + +/// Case-insensitive nickname / display-name match for the people sheet search field. +enum PeopleNameFilter { + /// Empty / whitespace-only queries match everything (no filter active). + static func matches(_ displayName: String, query: String) -> Bool { + let trimmed = query.trimmingCharacters(in: .whitespacesAndNewlines) + guard !trimmed.isEmpty else { return true } + return displayName.localizedCaseInsensitiveContains(trimmed) + } +}