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
[CIS-805] Refresh channel list queries when current user membership changes #1016
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just 1 little comment which you can probably ignore
@@ -8,9 +8,8 @@ public protocol ConnectionEvent: Event { | |||
var connectionId: String { get } | |||
} | |||
|
|||
public struct HealthCheckEvent: ConnectionEvent, EventWithPayload, EventWithCurrentUserPayload { | |||
public struct HealthCheckEvent: ConnectionEvent, EventWithPayload { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Thanks <3
updateChannelListQuery(for: channelDTO) | ||
database.write { | ||
let dto = $0.channel(cid: try! ChannelId(cid: channelDTO.cid)) | ||
dto?.needsRefreshQueries = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what is gooing on here 😅 Maybe add little documentation? This makes me wonder why it doesn't need to refresh queries...
try session.saveMember(payload: memberPayload, channelId: memberEvent.cid) | ||
case is MemberRemovedEvent: | ||
guard let channel = session.channel(cid: memberEvent.cid) else { | ||
try session.saveMember(payload: memberPayload, channelId: (event as! EventWithChannelId).cid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event as! EventWithChannelId
are we sure this is always true? Why the force unwrap? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MemberRemovedEvent
is always EventWithChannelId
:) @nuno-vieira
@@ -72,7 +72,14 @@ final class NewChannelQueryUpdater<ExtraData: ExtraDataTypes>: Worker { | |||
changes.forEach { change in | |||
switch change { | |||
case let .insert(channelDTO, _): | |||
updateChannelListQuery(for: channelDTO) | |||
database.write { | |||
let dto = $0.channel(cid: try! ChannelId(cid: channelDTO.cid)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this force unwrap safe as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Codecov Report
@@ Coverage Diff @@
## main #1016 +/- ##
==========================================
+ Coverage 89.78% 89.93% +0.14%
==========================================
Files 211 213 +2
Lines 8872 8943 +71
==========================================
+ Hits 7966 8043 +77
+ Misses 906 900 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
…hanges (#1016) * Expose `queries` field on `ChannelDTO` * Add `needsRefreshQueries` field to `ChannelDTO` * Make `NewChannelQueryUpdater` respect `needsRefreshQueries` * Make it possible to create mock channels with query * Streamline events protocols * Invalidate `ChannelDTO` queries when current user changes membership * Update CHANGELOG * fixup! Streamline events protocols
…hanges (#1016) * Expose `queries` field on `ChannelDTO` * Add `needsRefreshQueries` field to `ChannelDTO` * Make `NewChannelQueryUpdater` respect `needsRefreshQueries` * Make it possible to create mock channels with query * Streamline events protocols * Invalidate `ChannelDTO` queries when current user changes membership * Update CHANGELOG * fixup! Streamline events protocols
This PR makes the existing queries for a channel invalidated when the current user membership changes. In other words - when you stop being a member of a channel, you won't see it in the list :)