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 Channel List / Channels showing no data after reconnection #1435
Conversation
ConnectionRecoveryUpdater does nothing useful. it’s broken because it calls /sync with the wrong date (we don’t get missing events), furthermore it duplicates channel query calls (with wrong sorting if it’s different from default)
Removing channels completely leads to bugs where they're not unlinked from query. We should reset channel data (which would be recovered when channel is queried) and unlink channel
10d847b
to
d179cd7
Compare
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.
lets limit the changes to the least we needed
@@ -229,16 +229,7 @@ public class ChatClient { | |||
] | |||
|
|||
// All production event workers | |||
eventWorkerBuilders = [ |
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.
@b-onc better if you comment this instead deleting + add a /// patch comment
@@ -129,7 +129,7 @@ public class ChatChannelListController: DataController, DelegateCallable, DataSt | |||
callback: { [unowned self] in | |||
switch $0.webSocketConnectionState { | |||
case .connected: | |||
self.updateChannelList(trumpExistingChannels: self.channels.count > self.requestedChannelsLimit) | |||
self.updateChannelList(trumpExistingChannels: true) |
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.
AFAICT this is not a needed change, I would leave it alone
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.
Hm, I would have it 🤔
When we reconnect, we should invalidate history of local channels because there can be changes we are not aware of.
Use case:
- load 1st page (25 channels)
- go offline
- user becomes a member of a new channel that goes to 1st page (forcing locally existed channel X out from 1st page)
- smth changes in channel X outside the 1st page of messages
- go back online and do not trump local data
The history of channel X will be out of sync and user won't see the updates
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 would trump on synchronise/reconnect
no matter the storage setup. With no /sync
and enabled local storage, queries will go out of sync very soon
@@ -162,6 +162,8 @@ protocol ChannelDatabaseSession { | |||
query: ChannelListQuery? | |||
) throws -> ChannelDTO | |||
|
|||
@discardableResult func saveQuery(query: ChannelListQuery) -> ChannelListQueryDTO |
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.
out of scope
@@ -27,7 +27,8 @@ class ChannelListUpdater: Worker { | |||
self?.database.write { session in | |||
|
|||
if trumpExistingChannels { | |||
try session.deleteChannels(query: channelListQuery) | |||
let queryDTO = session.saveQuery(query: channelListQuery) |
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.
out of scope
@@ -72,7 +72,7 @@ class DatabaseCleanupUpdater: Worker { | |||
} | |||
} | |||
|
|||
private extension ChannelDTO { | |||
extension ChannelDTO { |
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.
out of scope
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.
Extension contains ChannelDTO .resetLocalData
used in channel list updater to trump a query -> we need this change 🙂
@@ -165,6 +165,10 @@ extension DatabaseSessionMock { | |||
underlyingSession.loadChannelReads(for: userId) | |||
} | |||
|
|||
func saveQuery(query: ChannelListQuery) -> ChannelListQueryDTO { |
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.
out of scope
Discussion in slack