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

Fix muted and joined channel list queries with empty data (Auto Filtering Enabled) #2634

Merged

Conversation

nuno-vieira
Copy link
Member

@nuno-vieira nuno-vieira commented May 19, 2023

🔗 Issue Links

Resolves https://github.com/GetStream/ios-issues-tracking/issues/423

🎯 Goal

Fix the channel list query being empty when the .muted and .joined filters were used with auto filtering enabled.

🛠 Implementation

We currently have an issue with our Auto Filtering where the .muted and .joined filters do not properly map to our DB predicates.

After some analysis and discussion with @ipavlidakis, we opted for introducing a PredicateMapper so that a filter can override the default Predicate logic.

🧪 Manual Testing Notes

Unit tests were added to prove it works correctly.

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change follows zero ⚠️ policy (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (docusaurus, tutorial, CMS)

@nuno-vieira nuno-vieira added 🐞 Bug An issue or PR related to a bug 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK labels May 19, 2023
@nuno-vieira nuno-vieira requested a review from a team as a code owner May 19, 2023 15:59
Copy link
Contributor

@ipavlidakis ipavlidakis left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@@ -111,13 +111,19 @@ public struct Filter<Scope: FilterScope> {
/// Whether the `keyPathString` represents an array in the DTO entities.
let isCollectionFilter: Bool

/// The mapper that will override the DB Predicate. This might be needed
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment is very helpful. Thanks for adding it!

switch op {
case .equal:
return NSPredicate(format: muted ? "\(key) != nil" : "\(key) == nil")
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

The code looks the same in both implementations (but the keyPath). Should we be reusing it by placing it in a single place? We are probably using the same logic in other places?

Copy link
Member Author

Choose a reason for hiding this comment

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

For now, I think it is fine to have a little duplication. We can introduce a helper to reuse this logic if we see more use cases like this. 👍

@sonarcloud
Copy link

sonarcloud bot commented May 22, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

96.4% 96.4% Coverage
0.0% 0.0% Duplication

@nuno-vieira nuno-vieira merged commit 9b89a7f into develop May 22, 2023
17 checks passed
@nuno-vieira nuno-vieira deleted the fix/muted-and-joined-channel-list-with-empty-data branch May 22, 2023 15:28
@nuno-vieira nuno-vieira mentioned this pull request May 24, 2023
This was referenced May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug An issue or PR related to a bug 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants