Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting searchType dynamically in ChatChannelListViewModel #693

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

laevandus
Copy link
Contributor

@laevandus laevandus commented Dec 18, 2024

🔗 Issue Link

Resolves IOS-603

🎯 Goal

Allow setting searchType dynamically in ChatChannelListViewModel

🛠 Implementation

Make searchType public in ChatChannelListViewModel and support reloading search results based on the type.

🧪 Testing

For testing purposes I added locally a button for toggling it (ChatChannelListView.swift)

VStack {
    Button("Toggle Results", action: {
        if viewModel.searchType == .messages {
            viewModel.searchType = .channels
        } else {
            viewModel.searchType = .messages
        }
    })
    ChatChannelListContentView(
        viewFactory: viewFactory,
        viewModel: viewModel,
        onItemTap: onItemTap
    )
}

🎨 Changes

Example

☑️ Checklist

  • I have signed the Stream CLA (required)
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Affected documentation updated (docusaurus, tutorial, CMS (task created)

@laevandus laevandus requested a review from a team as a code owner December 18, 2024 11:45
@laevandus laevandus force-pushed the feature/search-type-toggle branch from 89715f4 to 3e722f7 Compare December 18, 2024 11:47
@@ -393,10 +402,11 @@ open class ChatChannelListViewModel: ObservableObject, ChatChannelListController
/// Creates a new message search controller, sets its delegate, and triggers the search operation.
open func performMessageSearch() {
messageSearchController = chatClient.messageSearchController()
messageSearchController?.delegate = self
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it because otherwise delegate makes a callback with 0 results before sync finishes and this makes the UI to flash.

@@ -433,7 +443,7 @@ open class ChatChannelListViewModel: ObservableObject, ChatChannelListController
return ChannelSelectionInfo(
channel: channel,
message: message,
searchType: .channels
searchType: .messages
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI was flickering when changing the search type because incorrect search type was set here.

@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Dec 18, 2024

SDK Size

title develop branch diff status
StreamChatSwiftUI 7.53 MB 7.54 MB +1 KB 🟢

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@nuno-vieira nuno-vieira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅ we just need to fix the changelog

CHANGELOG.md Outdated Show resolved Hide resolved
@laevandus laevandus enabled auto-merge (squash) December 18, 2024 12:10
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
44.5% Coverage on New Code (required ≥ 70%)

See analysis details on SonarQube Cloud

@laevandus laevandus merged commit 0e26945 into develop Dec 18, 2024
11 of 12 checks passed
@laevandus laevandus deleted the feature/search-type-toggle branch December 18, 2024 12:44
@Stream-SDK-Bot Stream-SDK-Bot mentioned this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants