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 Channel List / Channels showing no data after reconnection #1435

Closed
wants to merge 2 commits into from

Conversation

b-onc
Copy link
Contributor

@b-onc b-onc commented Sep 9, 2021

Discussion in slack

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)
@b-onc b-onc added the 🐞 Bug An issue or PR related to a bug label Sep 9, 2021
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
@b-onc b-onc force-pushed the hotfix/channel-list-after-connection-recovery branch from 10d847b to d179cd7 Compare September 9, 2021 11:56
Copy link
Member

@tbarbugli tbarbugli left a 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 = [
Copy link
Member

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)
Copy link
Member

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

Copy link
Contributor

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:

  1. load 1st page (25 channels)
  2. go offline
  3. user becomes a member of a new channel that goes to 1st page (forcing locally existed channel X out from 1st page)
  4. smth changes in channel X outside the 1st page of messages
  5. 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

Copy link
Contributor

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
Copy link
Member

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)
Copy link
Member

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 {
Copy link
Member

Choose a reason for hiding this comment

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

out of scope

Copy link
Contributor

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 {
Copy link
Member

Choose a reason for hiding this comment

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

out of scope

@tbarbugli tbarbugli closed this Sep 10, 2021
@polqf polqf deleted the hotfix/channel-list-after-connection-recovery branch January 13, 2022 16:20
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants