mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-19 16:13:42 +02:00
#1098 - Working real user suggestion inside the main application.
This commit is contained in:
+2
-2
@@ -36,8 +36,8 @@ enum MockUserSuggestionScreenState: MockScreenState, CaseIterable {
|
||||
|
||||
let listViewModel = UserSuggestionViewModel.makeUserSuggestionViewModel(userSuggestionService: service)
|
||||
|
||||
let viewModel = UserSuggestionListWithInputViewModel(listViewModel: listViewModel) { partialUserName in
|
||||
service.processPartialUserName(partialUserName)
|
||||
let viewModel = UserSuggestionListWithInputViewModel(listViewModel: listViewModel) { textMessage in
|
||||
service.processTextMessage(textMessage)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
+19
-4
@@ -38,14 +38,29 @@ class MockUserSuggestionService: UserSuggestionServiceProtocol {
|
||||
items.send(suggestionItems)
|
||||
}
|
||||
|
||||
func processPartialUserName(_ userName: String) {
|
||||
guard userName.count > 0 else {
|
||||
items.send(suggestionItems)
|
||||
func processTextMessage(_ textMessage: String) {
|
||||
|
||||
items.send([])
|
||||
|
||||
guard textMessage.count > 0 else {
|
||||
return
|
||||
}
|
||||
|
||||
let components = textMessage.components(separatedBy: .whitespaces)
|
||||
|
||||
guard let lastComponent = components.last else {
|
||||
return
|
||||
}
|
||||
|
||||
guard lastComponent.hasPrefix("@") else {
|
||||
return
|
||||
}
|
||||
|
||||
var partialName = lastComponent
|
||||
partialName.removeFirst()
|
||||
|
||||
items.send(suggestionItems.filter({ userSuggestion in
|
||||
return (userSuggestion.displayName?.lowercased().range(of: userName.lowercased()) != .none)
|
||||
return (userSuggestion.displayName?.lowercased().range(of: partialName.lowercased()) != .none)
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user