mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-11-01 07:53:26 +00:00
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.
This commit is contained in:
parent
681c180060
commit
5b5adf2e2e
19
bitchat/Utils/PeopleNameFilter.swift
Normal file
19
bitchat/Utils/PeopleNameFilter.swift
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// PeopleNameFilter.swift
|
||||
// bitchat
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// For more information, see <https://unlicense.org>
|
||||
//
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user