Repository navigation
Conversation
Contributor
SDK Size Comparison 📏
|
Contributor
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Events sent while the WebSocket is down are never delivered, so loaded state can be out of date after a reconnection. Until now the SDK only watched feeds again. This PR makes a
Feedload its data again, and adds the pieces the other state objects will use for the same.It is the first of three PRs for parity with Swift (stream-feeds-swift#89). The paginated lists and
Activityfollow.Closes AND-2060
Implementation
ReconnectionRefetchHandlerkeeps the registered state objects weakly and refetches them all when the connection comes back with a new connection id. A newer reconnection cancels a refetch that is still running, and one object failing does not stop the others.refetchPagesloads pages from the start, with the query's own limit, until they cover the number of loaded items. It stops early when a page adds nothing new.PaginatedRefetchableis what a state object with a paginated list implements: its loaded count, how to fetch a page and how to apply the result. The loop is shared. It has the shape ofStateRefetchingin Swift, and the lists will use it in the next PR.Feedrefetches its feed data, followers, following, pinned activities and activities, and the follow requests if they were loaded. Activities are replaced once all their pages are loaded. Aggregated activities count as loaded items too.FeedsConfig.refetchOnReconnect(defaulttrue) turns it off.Good to know:
queryActivitiesAround. Swift does the same.FeedWatchHandler, and the handler skips that feed. The handler still watches again on its own when the refetch is turned off, on the first connection, and for watched feeds that are not loaded. iOS and Flutter also send a single request here.stopWatching, the refetch no longer watches the feed again.Testing
Unit tests cover the handler (first connection, reconnection, failures, cancellation, disabled), the paging loop, the feed refetch, and the watch handler skipping feeds that the refetch watches again.
On an emulator with the sample app: log in, send the app to the background and bring it back. The log shows
Refetching 5 state objects after reconnectionfollowed by the feed requests on the new connection.The emulator run was done before the watch and the refetch were folded into one request, and was not repeated after.
Not checked on a device: a change made by another user while disconnected showing up after the refetch.
Checklist