-
Notifications
You must be signed in to change notification settings - Fork 1
Feature: keep feed own capabilities up to date #51
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
Conversation
* Add middleware support to StateLayerEventPublisher * Add own capabilities middleware which enriches incoming WS events and extracts and stores own capabilities from local events * State layer explicitly saves own capabilities from get or query methods which do not post local events
|
|
||
| let user: UserData | ||
| let ownCapabilities: [FeedOwnCapability] | ||
| let ownCapabilities: Set<FeedOwnCapability> |
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.
For O(1) lookups
| /// A delay in seconds until feed own capabilities are fetched for feeds delivered through web-socket and there is no cached data available. | ||
| var automaticFeedOwnCapabilitiesFetchDelay: Int = 5 |
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.
Intentionally internal for now. Used by tests
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.
this feels a bit unnecessary imo
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.
OK, I'll take it away and we can add that if it becomes a problem. It should be rare that it gets triggered often (only thinking about the timeline feed case where new activities can point at many other feeds). But event then, most probably the state is already cached.
| func saveCapabilities(in feedData: FeedData?) -> [FeedId: Set<FeedOwnCapability>]? { | ||
| saveCapabilities(in: [feedData].compactMap { $0 }) | ||
| } |
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.
Convenience mostly for ActivityData.currentFeed (optional)
Generated by 🚫 Danger |
Public Interface public struct ActivityData: Identifiable, Equatable, Sendable
- public let currentFeed: FeedData?
+ public private var currentFeed: FeedData?
public struct FollowData: Equatable, Sendable
- public let sourceFeed: FeedData
+ public private var sourceFeed: FeedData
- public let targetFeed: FeedData
+ public private var targetFeed: FeedData
public struct BookmarkData: Equatable, Sendable
- public let activity: ActivityData
+ public private var activity: ActivityData
public struct FeedData: Identifiable, Equatable, Sendable
- public let ownCapabilities: [FeedOwnCapability]?
+ public private var ownCapabilities: Set<FeedOwnCapability>?
- public let ownFollows: [FollowData]?
+ public private var ownFollows: [FollowData]?
- public let ownMembership: FeedMemberData?
+ public private var ownMembership: FeedMemberData? |
SDK Size
|
|
StreamFeeds XCSize
Show 21 more objects
|
| case bodyType(Decodable.Type) | ||
| } | ||
|
|
||
| struct APIResponse { |
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.
We have tests where the order of requests is not serial, therefore a bit more sophisticated mocking is required. E.g. events can trigger capabilities fetch.



🔗 Issue Links
Fixes: IOS-1236
🎯 Goal
Keep
FeedData.ownCapabilitiesup to date when handling web-socket events📝 Summary
Additional context: SDK has
StateLayerEventPublisherwhich publishes events from web-socket events and from API calls (StateLayerEventis an enum).Feed,FeedList,Activity,ActivityList,BookmarkList,FollowListStateLayerEventPublisherfeedOwnCapabilitiesUpdatedfor propagating this data)Feed,FeedList,Activity,ActivityList,BookmarkList,FollowListActivity.currentFeed.ownCapabilitiesis nil).🛠 Implementation
Agreement was that, although local caching and updating is not ideal, there is not a viable way to workaround it on the backend side.
🎨 Showcase
🧪 Manual Testing Notes
☑️ Contributor Checklist
docs-contentrepo