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

Implement Local Filter processing for ChannelListController #2488

Merged

Conversation

ipavlidakis
Copy link
Contributor

@ipavlidakis ipavlidakis commented Feb 10, 2023

🔗 Issue Links

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

🎯 Goal

Allow local filter processing in order to reduce the need for a local filter block in ChannelListController.

🛠 Implementation

This PR implements the following:

  • Implement keyPathValueProvider for FilterKeys
  • Update the ChannelList related filterKeys, that can be filtered locally, to provide a valid keyPathValueProvider
  • Translation of API filters to DB filters (NSPredicates)
  • ChannelDTO fetchRequest creation was updated to include the filter's predicate - if not nil
  • Update tests

The logic is being described below:
FilterKeys that are compatible with local filter should provide a keyPathValueProvider. KeyPathValueProvider are closures that provide the keypath for the requested value or return nil if the value cannot be mapped.

The fetchRequest that the ChannelDTO, will include the filter's predicate if it's not nil. The fetchRequest can then be used to query the DB/

🧪 Manual Testing Notes

- Create a new Channel

  1. Open 2 Simulators and login with different users
  2. Create a new group with the 2 users + any other user you may need to add in order to ensure that a new group will be created
  3. Send a message
  4. The new channel should appear at the top of the list in both simulators

- Update an existing Channel

  1. Open 2 Simulators and login with different users
  2. Open an old existing channel with both our users
  3. Send a message
  4. The new channel should appear at the top of the list in both simulators

- Public API Changes

  • StreamRuntimeCheck.isChannelLocalFilteringEnabled: Bool (default: true): When the flag is true the ChannelDTO will use the filter's predicate to create the fetchRequest.

- Docusaurus Update Preview

Screenshot 2023-02-16 at 4 45 58 PM

☑️ 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)

🎁 Meme

meme

@ipavlidakis ipavlidakis self-assigned this Feb 10, 2023
@github-actions
Copy link

github-actions bot commented Feb 10, 2023

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@ipavlidakis ipavlidakis changed the title Implement LocalFilterProcessor Implement Local Filter processing for ChannelListController Feb 10, 2023
@ipavlidakis ipavlidakis marked this pull request as ready for review February 10, 2023 13:35
@ipavlidakis ipavlidakis requested a review from a team as a code owner February 10, 2023 13:35
@ipavlidakis ipavlidakis force-pushed the feature/local-channel-filter-matching-implementation branch from 5fdf56a to 03454f3 Compare February 14, 2023 10:15
@GetStream GetStream deleted a comment from emerge-tools bot Feb 14, 2023
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.

Overall looks good, just add some questions and suggested some improvements 👍

Sources/StreamChat/Config/StreamRuntimeCheck.swift Outdated Show resolved Hide resolved
Sources/StreamChat/Database/DTOs/ChannelDTO.swift Outdated Show resolved Hide resolved
Sources/StreamChat/Query/ChannelListQuery.swift Outdated Show resolved Hide resolved
Sources/StreamChat/Query/Filter+ChatChannel.swift Outdated Show resolved Hide resolved
Sources/StreamChat/Query/Filter.swift Outdated Show resolved Hide resolved
Sources/StreamChat/Query/Filter.swift Outdated Show resolved Hide resolved
ipavlidakis and others added 3 commits February 16, 2023 11:45
Co-authored-by: Nuno Vieira <nuno.fcvieira93@gmail.com>
@ipavlidakis ipavlidakis force-pushed the feature/local-channel-filter-matching-implementation branch from 184dbbc to 4a802b4 Compare February 16, 2023 12:43
Copy link
Contributor

@polqf polqf left a comment

Choose a reason for hiding this comment

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

All good, just couple of comments 👏 Looking forward to getting this out!!

Sources/StreamChat/Config/ChatClientConfig.swift Outdated Show resolved Hide resolved
docusaurus/docs/iOS/client/controllers/channels.md Outdated Show resolved Hide resolved
docusaurus/docs/iOS/client/controllers/channels.md Outdated Show resolved Hide resolved
Sources/StreamChat/Config/ChatClientConfig.swift Outdated Show resolved Hide resolved
docusaurus/docs/iOS/client/controllers/channels.md Outdated Show resolved Hide resolved
docusaurus/docs/iOS/client/controllers/channels.md Outdated Show resolved Hide resolved
docusaurus/docs/iOS/client/controllers/channels.md Outdated Show resolved Hide resolved
docusaurus/docs/iOS/client/controllers/channels.md Outdated Show resolved Hide resolved
docusaurus/docs/iOS/client/controllers/channels.md Outdated Show resolved Hide resolved
docusaurus/docs/iOS/client/controllers/channels.md Outdated Show resolved Hide resolved
@testableapple testableapple added 🟢 QAed A PR that was QAed and removed 🤞 Ready For QA A PR that is Ready for QA labels Feb 16, 2023
ipavlidakis and others added 9 commits February 16, 2023 16:47
+ Make Payloads conform to Hashable
+ Implement filter.KeyValueMapper
+ Update ChannelListQuery with the keyValueMappers for each FilterKey
+ Add tests
* Do not store messages from extension if app is receiving events

* Add tests for NotificationExtensionLifecycle

* Update tests for ChatRemoteNotificationHandler

* Add tests for NSManagedObjectContext.discard

* Address PR comments

* Do not set a default value for 'store' in MessageRepository.getMessage

* Fix specs compilation issue
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! ✅

CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Nuno Vieira <nuno.fcvieira93@gmail.com>
@sonarcloud
Copy link

sonarcloud bot commented Feb 16, 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 6 Code Smells

93.8% 93.8% Coverage
0.0% 0.0% Duplication

@ipavlidakis ipavlidakis merged commit 96e17c6 into develop Feb 16, 2023
@ipavlidakis ipavlidakis deleted the feature/local-channel-filter-matching-implementation branch February 16, 2023 17:33
@polqf polqf mentioned this pull request Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🟢 QAed A PR that was QAed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants