@stream-io/feeds-client 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/cjs/index.js +408 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/react-bindings.js +1368 -0
- package/dist/cjs/react-bindings.js.map +1 -0
- package/dist/es/index.mjs +398 -0
- package/dist/es/index.mjs.map +1 -0
- package/dist/es/react-bindings.mjs +1368 -0
- package/dist/es/react-bindings.mjs.map +1 -0
- package/dist/index-Cfbt0DFY.js +6492 -0
- package/dist/index-Cfbt0DFY.js.map +1 -0
- package/dist/index-DLC5hiNd.mjs +6476 -0
- package/dist/index-DLC5hiNd.mjs.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/bindings/index.d.ts +2 -0
- package/dist/types/bindings/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/contexts/StreamFeedContext.d.ts +2 -1
- package/dist/types/bindings/react/contexts/StreamFeedContext.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/contexts/StreamFeedsContext.d.ts +2 -1
- package/dist/types/bindings/react/contexts/StreamFeedsContext.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/contexts/StreamSearchContext.d.ts +2 -1
- package/dist/types/bindings/react/contexts/StreamSearchContext.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/contexts/StreamSearchResultsContext.d.ts +2 -1
- package/dist/types/bindings/react/contexts/StreamSearchResultsContext.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/client-state-hooks/index.d.ts +1 -0
- package/dist/types/bindings/react/hooks/client-state-hooks/index.d.ts.map +1 -0
- package/dist/types/bindings/react/hooks/client-state-hooks/useClientConnectedUser.d.ts +5 -0
- package/dist/types/bindings/react/hooks/client-state-hooks/useClientConnectedUser.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/client-state-hooks/useWsConnectionState.d.ts +1 -0
- package/dist/types/bindings/react/hooks/client-state-hooks/useWsConnectionState.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/index.d.ts +1 -0
- package/dist/types/bindings/react/hooks/feed-state-hooks/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useAggregatedActivities.d.ts +3 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useAggregatedActivities.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useComments.d.ts +2 -3
- package/dist/types/bindings/react/hooks/feed-state-hooks/useComments.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useFeedActivities.d.ts +3 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useFeedActivities.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useFeedMetadata.d.ts +3 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useFeedMetadata.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useFollowers.d.ts +5 -4
- package/dist/types/bindings/react/hooks/feed-state-hooks/useFollowers.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useFollowing.d.ts +5 -4
- package/dist/types/bindings/react/hooks/feed-state-hooks/useFollowing.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useIsAggregatedActivityRead.d.ts +2 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivityRead.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useIsAggregatedActivitySeen.d.ts +2 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivitySeen.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useNotificationStatus.d.ts +2 -1
- package/dist/types/bindings/react/hooks/feed-state-hooks/useNotificationStatus.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useOwnCapabilities.d.ts +2 -1
- package/dist/types/bindings/react/hooks/feed-state-hooks/useOwnCapabilities.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useOwnFollows.d.ts +3 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useOwnFollows.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/internal/index.d.ts +1 -0
- package/dist/types/bindings/react/hooks/internal/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/internal/useStableCallback.d.ts +1 -0
- package/dist/types/bindings/react/hooks/internal/useStableCallback.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/search-state-hooks/index.d.ts +1 -0
- package/dist/types/bindings/react/hooks/search-state-hooks/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/search-state-hooks/useSearchQuery.d.ts +2 -1
- package/dist/types/bindings/react/hooks/search-state-hooks/useSearchQuery.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/search-state-hooks/useSearchResult.d.ts +2 -1
- package/dist/types/bindings/react/hooks/search-state-hooks/useSearchResult.d.ts.map +1 -0
- package/dist/types/bindings/react/hooks/search-state-hooks/useSearchSources.d.ts +5 -0
- package/dist/types/bindings/react/hooks/search-state-hooks/useSearchSources.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/useCreateFeedsClient.d.ts +2 -4
- package/dist/types/bindings/react/hooks/useCreateFeedsClient.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/util/index.d.ts +1 -0
- package/dist/types/bindings/react/hooks/util/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/util/useBookmarkActions.d.ts +2 -1
- package/dist/types/bindings/react/hooks/util/useBookmarkActions.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/util/useReactionActions.d.ts +2 -1
- package/dist/types/bindings/react/hooks/util/useReactionActions.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/index.d.ts +2 -1
- package/dist/types/bindings/react/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/wrappers/StreamFeed.d.ts +2 -1
- package/dist/types/bindings/react/wrappers/StreamFeed.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/wrappers/StreamFeeds.d.ts +1 -0
- package/dist/types/bindings/react/wrappers/StreamFeeds.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/wrappers/StreamSearch.d.ts +2 -1
- package/dist/types/bindings/react/wrappers/StreamSearch.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/wrappers/StreamSearchResults.d.ts +2 -1
- package/dist/types/bindings/react/wrappers/StreamSearchResults.d.ts.map +1 -0
- package/dist/{src → types}/common/ApiClient.d.ts +18 -0
- package/dist/types/common/ApiClient.d.ts.map +1 -0
- package/dist/{src → types}/common/ConnectionIdManager.d.ts +1 -0
- package/dist/types/common/ConnectionIdManager.d.ts.map +1 -0
- package/dist/{src → types}/common/EventDispatcher.d.ts +1 -0
- package/dist/types/common/EventDispatcher.d.ts.map +1 -0
- package/dist/{src → types}/common/Poll.d.ts +2 -1
- package/dist/types/common/Poll.d.ts.map +1 -0
- package/dist/{src → types}/common/TokenManager.d.ts +2 -0
- package/dist/types/common/TokenManager.d.ts.map +1 -0
- package/dist/{src → types}/common/gen-imports.d.ts +1 -0
- package/dist/types/common/gen-imports.d.ts.map +1 -0
- package/dist/{src → types}/common/rate-limit.d.ts +1 -0
- package/dist/types/common/rate-limit.d.ts.map +1 -0
- package/dist/{src → types}/common/real-time/StableWSConnection.d.ts +4 -4
- package/dist/types/common/real-time/StableWSConnection.d.ts.map +1 -0
- package/dist/{src → types}/common/real-time/event-models.d.ts +1 -0
- package/dist/types/common/real-time/event-models.d.ts.map +1 -0
- package/dist/{src → types}/common/search/ActivitySearchSource.d.ts +1 -0
- package/dist/types/common/search/ActivitySearchSource.d.ts.map +1 -0
- package/dist/{src → types}/common/search/BaseSearchSource.d.ts +2 -1
- package/dist/types/common/search/BaseSearchSource.d.ts.map +1 -0
- package/dist/{src → types}/common/search/FeedSearchSource.d.ts +1 -0
- package/dist/types/common/search/FeedSearchSource.d.ts.map +1 -0
- package/dist/{src → types}/common/search/SearchController.d.ts +2 -1
- package/dist/types/common/search/SearchController.d.ts.map +1 -0
- package/dist/{src → types}/common/search/UserSearchSource.d.ts +2 -1
- package/dist/types/common/search/UserSearchSource.d.ts.map +1 -0
- package/dist/{src → types}/common/search/index.d.ts +1 -0
- package/dist/types/common/search/index.d.ts.map +1 -0
- package/dist/{src → types}/common/search/types.d.ts +1 -0
- package/dist/types/common/search/types.d.ts.map +1 -0
- package/dist/{src → types}/common/types.d.ts +3 -1
- package/dist/types/common/types.d.ts.map +1 -0
- package/dist/{src → types}/common/utils.d.ts +1 -0
- package/dist/types/common/utils.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-added.d.ts +3 -2
- package/dist/types/feed/event-handlers/activity/handle-activity-added.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-deleted.d.ts +3 -2
- package/dist/types/feed/event-handlers/activity/handle-activity-deleted.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-marked.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-marked.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-pinned.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-pinned.d.ts.map +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-reaction-added.d.ts +15 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-reaction-added.d.ts.map +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-reaction-deleted.d.ts +15 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-reaction-deleted.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-removed-from-feed.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-removed-from-feed.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-unpinned.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-unpinned.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/bookmark/handle-bookmark-added.d.ts +1 -0
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-added.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/bookmark/handle-bookmark-deleted.d.ts +1 -0
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-deleted.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/bookmark/handle-bookmark-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/bookmark/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/bookmark/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/comment/handle-comment-added.d.ts +1 -0
- package/dist/types/feed/event-handlers/comment/handle-comment-added.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/comment/handle-comment-deleted.d.ts +1 -0
- package/dist/types/feed/event-handlers/comment/handle-comment-deleted.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/comment/handle-comment-reaction.d.ts +1 -0
- package/dist/types/feed/event-handlers/comment/handle-comment-reaction.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/comment/handle-comment-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/comment/handle-comment-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/comment/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/comment/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed/handle-feed-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed/handle-feed-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed-member/handle-feed-member-added.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-added.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed-member/handle-feed-member-removed.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-removed.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed-member/handle-feed-member-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed-member/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed-member/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/follow/handle-follow-created.d.ts +3 -2
- package/dist/types/feed/event-handlers/follow/handle-follow-created.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/follow/handle-follow-deleted.d.ts +2 -1
- package/dist/types/feed/event-handlers/follow/handle-follow-deleted.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/follow/handle-follow-updated.d.ts +3 -2
- package/dist/types/feed/event-handlers/follow/handle-follow-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/follow/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/follow/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/notification-feed/handle-notification-feed-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/notification-feed/handle-notification-feed-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/notification-feed/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/notification-feed/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/watch/handle-watch-started.d.ts +1 -0
- package/dist/types/feed/event-handlers/watch/handle-watch-started.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/watch/handle-watch-stopped.d.ts +1 -0
- package/dist/types/feed/event-handlers/watch/handle-watch-stopped.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/watch/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/watch/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/feed.d.ts +9 -6
- package/dist/types/feed/feed.d.ts.map +1 -0
- package/dist/{src → types}/feed/index.d.ts +1 -0
- package/dist/types/feed/index.d.ts.map +1 -0
- package/dist/{src → types}/feeds-client/event-handlers/index.d.ts +1 -0
- package/dist/types/feeds-client/event-handlers/index.d.ts.map +1 -0
- package/dist/{src → types}/feeds-client/event-handlers/user/handle-user-updated.d.ts +1 -0
- package/dist/types/feeds-client/event-handlers/user/handle-user-updated.d.ts.map +1 -0
- package/dist/{src → types}/feeds-client/feeds-client.d.ts +18 -10
- package/dist/types/feeds-client/feeds-client.d.ts.map +1 -0
- package/dist/{src → types}/feeds-client/index.d.ts +1 -0
- package/dist/types/feeds-client/index.d.ts.map +1 -0
- package/dist/{src → types}/gen/feeds/FeedApi.d.ts +1 -0
- package/dist/types/gen/feeds/FeedApi.d.ts.map +1 -0
- package/dist/{src → types}/gen/feeds/FeedsApi.d.ts +1 -0
- package/dist/types/gen/feeds/FeedsApi.d.ts.map +1 -0
- package/dist/{src → types}/gen/model-decoders/decoders.d.ts +1 -0
- package/dist/types/gen/model-decoders/decoders.d.ts.map +1 -0
- package/dist/{src → types}/gen/model-decoders/event-decoder-mapping.d.ts +1 -0
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts.map +1 -0
- package/dist/{src → types}/gen/models/index.d.ts +43 -1
- package/dist/types/gen/models/index.d.ts.map +1 -0
- package/dist/{src → types}/gen/moderation/ModerationApi.d.ts +1 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts.map +1 -0
- package/dist/{src → types}/gen-imports.d.ts +1 -0
- package/dist/types/gen-imports.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{src → types}/moderation-client.d.ts +1 -0
- package/dist/types/moderation-client.d.ts.map +1 -0
- package/dist/{src → types}/types-internal.d.ts +4 -0
- package/dist/types/types-internal.d.ts.map +1 -0
- package/dist/{src → types}/types.d.ts +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/{src → types}/utils/check-has-another-page.d.ts +1 -0
- package/dist/types/utils/check-has-another-page.d.ts.map +1 -0
- package/dist/{src → types}/utils/constants.d.ts +1 -0
- package/dist/types/utils/constants.d.ts.map +1 -0
- package/dist/{src → types}/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/is-react-native.d.ts +5 -0
- package/dist/types/utils/is-react-native.d.ts.map +1 -0
- package/dist/types/utils/logger.d.ts +61 -0
- package/dist/types/utils/logger.d.ts.map +1 -0
- package/dist/types/utils/state-update-queue.d.ts +83 -0
- package/dist/types/utils/state-update-queue.d.ts.map +1 -0
- package/dist/types/utils/type-assertions.d.ts +12 -0
- package/dist/types/utils/type-assertions.d.ts.map +1 -0
- package/dist/{src → types}/utils/unique-array-merge.d.ts +1 -0
- package/dist/types/utils/unique-array-merge.d.ts.map +1 -0
- package/dist/{src → types}/utils/update-entity-in-array.d.ts +1 -0
- package/dist/types/utils/update-entity-in-array.d.ts.map +1 -0
- package/package.json +21 -33
- package/src/bindings/index.ts +1 -0
- package/src/bindings/react/contexts/StreamFeedContext.tsx +18 -0
- package/src/bindings/react/contexts/StreamFeedsContext.tsx +21 -0
- package/src/bindings/react/contexts/StreamSearchContext.tsx +18 -0
- package/src/bindings/react/contexts/StreamSearchResultsContext.tsx +20 -0
- package/src/bindings/react/hooks/client-state-hooks/useClientConnectedUser.ts +18 -0
- package/src/bindings/react/hooks/client-state-hooks/useWsConnectionState.ts +18 -0
- package/src/bindings/react/hooks/feed-state-hooks/useAggregatedActivities.ts +25 -0
- package/src/bindings/react/hooks/feed-state-hooks/useComments.ts +91 -0
- package/src/bindings/react/hooks/feed-state-hooks/useFeedActivities.ts +36 -0
- package/src/bindings/react/hooks/feed-state-hooks/useFeedMetadata.ts +28 -0
- package/src/bindings/react/hooks/feed-state-hooks/useFollowers.ts +54 -0
- package/src/bindings/react/hooks/feed-state-hooks/useFollowing.ts +54 -0
- package/src/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivityRead.ts +29 -0
- package/src/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivitySeen.ts +28 -0
- package/src/bindings/react/hooks/feed-state-hooks/useNotificationStatus.ts +28 -0
- package/src/bindings/react/hooks/feed-state-hooks/useOwnCapabilities.ts +70 -0
- package/src/bindings/react/hooks/feed-state-hooks/useOwnFollows.ts +18 -0
- package/src/bindings/react/hooks/internal/useStableCallback.ts +37 -0
- package/src/bindings/react/hooks/search-state-hooks/useSearchQuery.ts +14 -0
- package/src/bindings/react/hooks/search-state-hooks/useSearchResult.ts +36 -0
- package/src/bindings/react/hooks/search-state-hooks/useSearchSources.ts +17 -0
- package/src/bindings/react/hooks/useCreateFeedsClient.ts +73 -0
- package/src/bindings/react/hooks/util/useBookmarkActions.ts +40 -0
- package/src/bindings/react/hooks/util/useReactionActions.ts +56 -0
- package/{@react-bindings → src/bindings/react}/index.ts +1 -1
- package/src/bindings/react/wrappers/StreamFeed.tsx +23 -0
- package/src/bindings/react/wrappers/StreamFeeds.tsx +13 -0
- package/src/bindings/react/wrappers/StreamSearch.tsx +23 -0
- package/src/bindings/react/wrappers/StreamSearchResults.tsx +23 -0
- package/src/common/ApiClient.ts +86 -33
- package/src/common/EventDispatcher.ts +3 -6
- package/src/common/Poll.ts +1 -1
- package/src/common/TokenManager.ts +4 -0
- package/src/common/real-time/StableWSConnection.ts +64 -60
- package/src/common/search/BaseSearchSource.ts +11 -4
- package/src/common/search/SearchController.ts +4 -2
- package/src/common/types.ts +3 -2
- package/src/feed/event-handlers/activity/activity-utils.test.ts +40 -9
- package/src/feed/event-handlers/activity/handle-activity-added.test.ts +1 -1
- package/src/feed/event-handlers/activity/handle-activity-added.ts +7 -7
- package/src/feed/event-handlers/activity/handle-activity-deleted.ts +15 -12
- package/src/feed/event-handlers/activity/handle-activity-reaction-added.test.ts +101 -1
- package/src/feed/event-handlers/activity/handle-activity-reaction-added.ts +55 -29
- package/src/feed/event-handlers/activity/handle-activity-reaction-deleted.test.ts +118 -1
- package/src/feed/event-handlers/activity/handle-activity-reaction-deleted.ts +59 -32
- package/src/feed/event-handlers/activity/handle-activity-removed-from-feed.ts +1 -1
- package/src/feed/event-handlers/follow/follow-state-update-queue.test.ts +219 -0
- package/src/feed/event-handlers/follow/handle-follow-created.ts +7 -2
- package/src/feed/event-handlers/follow/handle-follow-deleted.ts +5 -0
- package/src/feed/event-handlers/follow/handle-follow-updated.test.ts +0 -43
- package/src/feed/event-handlers/follow/handle-follow-updated.ts +7 -2
- package/src/feed/feed.test.ts +90 -0
- package/src/feed/feed.ts +25 -4
- package/src/feeds-client/feeds-client.ts +35 -4
- package/src/gen/feeds/FeedsApi.ts +2 -0
- package/src/gen/model-decoders/decoders.ts +22 -0
- package/src/gen/models/index.ts +71 -1
- package/src/index.ts +9 -0
- package/src/test-utils/response-generators.ts +12 -3
- package/src/types-internal.ts +4 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/is-react-native.ts +7 -0
- package/src/utils/logger.ts +18 -0
- package/src/utils/state-update-queue.test.ts +85 -9
- package/src/utils/state-update-queue.ts +104 -11
- package/src/utils/type-assertions.ts +22 -1
- package/dist/@react-bindings/hooks/client-state-hooks/useClientConnectedUser.d.ts +0 -4
- package/dist/@react-bindings/hooks/search-state-hooks/useSearchSources.d.ts +0 -4
- package/dist/@react-bindings/hooks/useStateStore.d.ts +0 -3
- package/dist/index-react-bindings.browser.cjs +0 -6607
- package/dist/index-react-bindings.browser.cjs.map +0 -1
- package/dist/index-react-bindings.browser.js +0 -6574
- package/dist/index-react-bindings.browser.js.map +0 -1
- package/dist/index-react-bindings.node.cjs +0 -6607
- package/dist/index-react-bindings.node.cjs.map +0 -1
- package/dist/index-react-bindings.node.js +0 -6574
- package/dist/index-react-bindings.node.js.map +0 -1
- package/dist/index.browser.cjs +0 -6578
- package/dist/index.browser.cjs.map +0 -1
- package/dist/index.browser.js +0 -6551
- package/dist/index.browser.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.node.cjs +0 -6578
- package/dist/index.node.cjs.map +0 -1
- package/dist/index.node.js +0 -6551
- package/dist/index.node.js.map +0 -1
- package/dist/src/common/StateStore.d.ts +0 -125
- package/dist/src/feed/event-handlers/activity/handle-activity-reaction-added.d.ts +0 -12
- package/dist/src/feed/event-handlers/activity/handle-activity-reaction-deleted.d.ts +0 -12
- package/dist/src/utils/state-update-queue.d.ts +0 -6
- package/dist/src/utils/type-assertions.d.ts +0 -7
- package/index.ts +0 -9
- package/src/common/StateStore.ts +0 -332
- /package/{@react-bindings → src/bindings/react}/hooks/client-state-hooks/index.ts +0 -0
- /package/{@react-bindings → src/bindings/react}/hooks/feed-state-hooks/index.ts +0 -0
- /package/{@react-bindings → src/bindings/react}/hooks/internal/index.ts +0 -0
- /package/{@react-bindings → src/bindings/react}/hooks/search-state-hooks/index.ts +0 -0
- /package/{@react-bindings → src/bindings/react}/hooks/util/index.ts +0 -0
package/package.json
CHANGED
|
@@ -1,48 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/feeds-client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"packageManager": "yarn@3.2.4",
|
|
5
|
-
"main": "./dist/index.
|
|
5
|
+
"main": "./dist/es/index.mjs",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
9
|
"react-native": {
|
|
10
|
-
"import": "./dist/index.
|
|
11
|
-
"require": "./dist/index.
|
|
10
|
+
"import": "./dist/es/index.mjs",
|
|
11
|
+
"require": "./dist/cjs/index.js"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
"node": {
|
|
18
|
-
"import": "./dist/index.node.js",
|
|
19
|
-
"require": "./dist/index.node.cjs"
|
|
20
|
-
},
|
|
21
|
-
"default": "./dist/index.node.js"
|
|
13
|
+
"import": "./dist/es/index.mjs",
|
|
14
|
+
"require": "./dist/cjs/index.js",
|
|
15
|
+
"default": "./dist/es/index.mjs"
|
|
22
16
|
},
|
|
23
17
|
"./react-bindings": {
|
|
24
|
-
"types": "./dist
|
|
18
|
+
"types": "./dist/types/bindings/react/index.d.ts",
|
|
25
19
|
"react-native": {
|
|
26
|
-
"import": "./dist/
|
|
27
|
-
"require": "./dist/
|
|
28
|
-
},
|
|
29
|
-
"browser": {
|
|
30
|
-
"import": "./dist/index-react-bindings.browser.js",
|
|
31
|
-
"require": "./dist/index-react-bindings.browser.cjs"
|
|
32
|
-
},
|
|
33
|
-
"node": {
|
|
34
|
-
"import": "./dist/index-react-bindings.node.js",
|
|
35
|
-
"require": "./dist/index-react-bindings.node.cjs"
|
|
20
|
+
"import": "./dist/es/react-bindings.mjs",
|
|
21
|
+
"require": "./dist/cjs/react-bindings.js"
|
|
36
22
|
},
|
|
37
|
-
"
|
|
23
|
+
"import": "./dist/es/react-bindings.mjs",
|
|
24
|
+
"require": "./dist/cjs/react-bindings.js",
|
|
25
|
+
"default": "./dist/es/react-bindings.mjs"
|
|
38
26
|
}
|
|
39
27
|
},
|
|
40
28
|
"types": "./dist/index.d.ts",
|
|
41
29
|
"license": "See license in LICENSE",
|
|
42
30
|
"scripts": {
|
|
43
31
|
"clean": "rimraf dist",
|
|
44
|
-
"start": "
|
|
45
|
-
"build": "yarn clean
|
|
32
|
+
"start": "yarn clean; concurrently 'vite build --watch' 'tsc --watch'",
|
|
33
|
+
"build": "yarn clean; concurrently 'vite build' 'tsc'",
|
|
46
34
|
"test": "vitest",
|
|
47
35
|
"test:unit": "vitest --exclude '__integration-tests__/**'",
|
|
48
36
|
"test-ci": "vitest --exclude '__integration-tests__/docs-snippets/**' --coverage",
|
|
@@ -58,22 +46,22 @@
|
|
|
58
46
|
"CHANGELOG.md"
|
|
59
47
|
],
|
|
60
48
|
"dependencies": {
|
|
49
|
+
"@stream-io/logger": "^1.1.4",
|
|
50
|
+
"@stream-io/state-store": "^1.1.4",
|
|
61
51
|
"axios": "^1.7.7"
|
|
62
52
|
},
|
|
63
53
|
"devDependencies": {
|
|
64
|
-
"@rollup/plugin-replace": "^6.0.1",
|
|
65
|
-
"@rollup/plugin-typescript": "^12.1.0",
|
|
66
54
|
"@stream-io/node-sdk": "0.6.0",
|
|
67
55
|
"@types/react": "^19.1.8",
|
|
68
56
|
"@vitest/coverage-v8": "3.2.4",
|
|
57
|
+
"concurrently": "^9.2.1",
|
|
69
58
|
"dotenv": "^16.4.5",
|
|
70
59
|
"human-id": "^4.1.1",
|
|
71
60
|
"react": "19.0.0",
|
|
72
61
|
"rimraf": "^6.0.1",
|
|
73
|
-
"rollup": "^4.24.0",
|
|
74
62
|
"typescript": "^5.8.3",
|
|
75
|
-
"vite": "^
|
|
76
|
-
"vitest": "^3.2.
|
|
63
|
+
"vite": "^7.1.5",
|
|
64
|
+
"vitest": "^3.2.4"
|
|
77
65
|
},
|
|
78
66
|
"peerDependencies": {
|
|
79
67
|
"react": "^18 || ^19"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './react';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import type { Feed } from '@self';
|
|
3
|
+
|
|
4
|
+
export const StreamFeedContext = createContext<Feed | undefined>(undefined);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The props for the StreamFeedProvider component.
|
|
8
|
+
*/
|
|
9
|
+
export type StreamFeedContextProps = {
|
|
10
|
+
feed: Feed;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Hook to access the nearest Feed instance.
|
|
15
|
+
*/
|
|
16
|
+
export const useFeedContext = () => {
|
|
17
|
+
return useContext(StreamFeedContext);
|
|
18
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import type { FeedsClient } from '@self';
|
|
3
|
+
|
|
4
|
+
export const StreamFeedsContext = createContext<FeedsClient | undefined>(undefined);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The props for the StreamFeedsProvider component.
|
|
8
|
+
*/
|
|
9
|
+
export type StreamFeedsContextProps = {
|
|
10
|
+
/**
|
|
11
|
+
* The client instance to provide to the component tree.
|
|
12
|
+
*/
|
|
13
|
+
client: FeedsClient;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Hook to access the nearest FeedsClient instance.
|
|
18
|
+
*/
|
|
19
|
+
export const useFeedsClient = () => {
|
|
20
|
+
return useContext(StreamFeedsContext);
|
|
21
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import type { SearchController } from '@self';
|
|
3
|
+
|
|
4
|
+
export const StreamSearchContext = createContext<SearchController | undefined>(undefined);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The props for the StreamSearchProvider component.
|
|
8
|
+
*/
|
|
9
|
+
export type StreamSearchContextProps = {
|
|
10
|
+
searchController: SearchController;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Hook to access the nearest SearchController instance.
|
|
15
|
+
*/
|
|
16
|
+
export const useSearchContext = () => {
|
|
17
|
+
return useContext(StreamSearchContext);
|
|
18
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import type { SearchSource } from '@self';
|
|
3
|
+
|
|
4
|
+
export const StreamSearchResultsContext = createContext<
|
|
5
|
+
SearchSource | undefined
|
|
6
|
+
>(undefined);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The props for the StreamSearchResultsProvider component.
|
|
10
|
+
*/
|
|
11
|
+
export type StreamSearchResultsContextProps = {
|
|
12
|
+
source: SearchSource;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Hook to access the nearest SearchSource instance.
|
|
17
|
+
*/
|
|
18
|
+
export const useSearchResultsContext = () => {
|
|
19
|
+
return useContext(StreamSearchResultsContext);
|
|
20
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FeedsClientState } from '@self';
|
|
2
|
+
import { useStateStore } from '@stream-io/state-store/react-bindings';
|
|
3
|
+
import { useFeedsClient } from '../../contexts/StreamFeedsContext';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A React hook that returns the currently connected user on a `FeedsClient` instance and null otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export const useClientConnectedUser = () => {
|
|
9
|
+
const client = useFeedsClient();
|
|
10
|
+
|
|
11
|
+
const { user } = useStateStore(client?.state, selector) ?? {};
|
|
12
|
+
|
|
13
|
+
return user;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const selector = (nextState: FeedsClientState) => ({
|
|
17
|
+
user: nextState.connected_user,
|
|
18
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FeedsClientState } from '@self';
|
|
2
|
+
import { useStateStore } from '@stream-io/state-store/react-bindings';
|
|
3
|
+
import { useFeedsClient } from '../../contexts/StreamFeedsContext';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A React hook that returns the websocket connection state of `FeedsClient`.
|
|
7
|
+
*/
|
|
8
|
+
export const useWsConnectionState = () => {
|
|
9
|
+
const client = useFeedsClient();
|
|
10
|
+
|
|
11
|
+
const { is_healthy } = useStateStore(client?.state, selector) ?? {}
|
|
12
|
+
|
|
13
|
+
return { is_healthy };
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const selector = (nextState: FeedsClientState) => ({
|
|
17
|
+
is_healthy: nextState.is_ws_connection_healthy,
|
|
18
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Feed, FeedState } from '@self';
|
|
2
|
+
import { useStateStore } from '@stream-io/state-store/react-bindings';
|
|
3
|
+
import { useFeedContext } from '../../contexts/StreamFeedContext';
|
|
4
|
+
|
|
5
|
+
const selector = ({ aggregated_activities }: FeedState) => ({
|
|
6
|
+
aggregated_activities,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
type UseAggregatedActivitiesReturnType = ReturnType<typeof selector>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A React hook that returns a reactive object containing the current aggregated activities.
|
|
13
|
+
*/
|
|
14
|
+
export function useAggregatedActivities(
|
|
15
|
+
feedFromProps: Feed,
|
|
16
|
+
): UseAggregatedActivitiesReturnType;
|
|
17
|
+
export function useAggregatedActivities(
|
|
18
|
+
feedFromProps?: Feed,
|
|
19
|
+
): UseAggregatedActivitiesReturnType | undefined;
|
|
20
|
+
export function useAggregatedActivities(feedFromProps?: Feed) {
|
|
21
|
+
const feedFromContext = useFeedContext();
|
|
22
|
+
const feed = feedFromProps ?? feedFromContext;
|
|
23
|
+
|
|
24
|
+
return useStateStore(feed?.state, selector);
|
|
25
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
type ActivityResponse,
|
|
4
|
+
type CommentResponse,
|
|
5
|
+
type CommentParent,
|
|
6
|
+
type Feed,
|
|
7
|
+
type FeedState,
|
|
8
|
+
checkHasAnotherPage,
|
|
9
|
+
isCommentResponse,
|
|
10
|
+
} from '@self';
|
|
11
|
+
import { useStateStore } from '@stream-io/state-store/react-bindings';
|
|
12
|
+
import { useFeedContext } from '../../contexts/StreamFeedContext';
|
|
13
|
+
|
|
14
|
+
type UseCommentsReturnType<T extends ActivityResponse | CommentResponse> = {
|
|
15
|
+
comments: NonNullable<
|
|
16
|
+
FeedState['comments_by_entity_id'][T['id']]
|
|
17
|
+
>['comments'];
|
|
18
|
+
comments_pagination: NonNullable<
|
|
19
|
+
FeedState['comments_by_entity_id'][T['id']]
|
|
20
|
+
>['pagination'];
|
|
21
|
+
has_next_page: boolean;
|
|
22
|
+
is_loading_next_page: boolean;
|
|
23
|
+
loadNextPage: (
|
|
24
|
+
request?: T extends CommentResponse
|
|
25
|
+
? Parameters<Feed['loadNextPageCommentReplies']>[1]
|
|
26
|
+
: Parameters<Feed['loadNextPageActivityComments']>[1],
|
|
27
|
+
) => Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function useComments<T extends CommentParent>(_: {
|
|
31
|
+
feed: Feed;
|
|
32
|
+
parent: T;
|
|
33
|
+
}): UseCommentsReturnType<T>;
|
|
34
|
+
export function useComments<T extends CommentParent>(_: {
|
|
35
|
+
feed?: Feed;
|
|
36
|
+
parent: T;
|
|
37
|
+
}): UseCommentsReturnType<T> | undefined;
|
|
38
|
+
export function useComments<T extends CommentParent>({
|
|
39
|
+
feed: feedFromProps,
|
|
40
|
+
parent,
|
|
41
|
+
}: {
|
|
42
|
+
feed?: Feed;
|
|
43
|
+
/**
|
|
44
|
+
* The parent (activity or comment) for which to fetch comments.
|
|
45
|
+
*/
|
|
46
|
+
parent: T;
|
|
47
|
+
}) {
|
|
48
|
+
const feedFromContext = useFeedContext();
|
|
49
|
+
const feed = feedFromProps ?? feedFromContext;
|
|
50
|
+
|
|
51
|
+
const selector = useCallback(
|
|
52
|
+
(state: FeedState) => ({
|
|
53
|
+
comments: state.comments_by_entity_id?.[parent.id]?.comments,
|
|
54
|
+
comments_pagination: state.comments_by_entity_id?.[parent.id]?.pagination,
|
|
55
|
+
}),
|
|
56
|
+
[parent.id],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const data = useStateStore(feed?.state, selector);
|
|
60
|
+
|
|
61
|
+
const loadNextPage = useMemo<
|
|
62
|
+
UseCommentsReturnType<T>['loadNextPage'] | undefined
|
|
63
|
+
>(() => {
|
|
64
|
+
if (!feed) return undefined;
|
|
65
|
+
|
|
66
|
+
return (request) => {
|
|
67
|
+
if (isCommentResponse(parent)) {
|
|
68
|
+
return feed.loadNextPageCommentReplies(parent, request);
|
|
69
|
+
} else {
|
|
70
|
+
return feed.loadNextPageActivityComments(parent, request);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}, [feed, parent]);
|
|
74
|
+
|
|
75
|
+
return useMemo(() => {
|
|
76
|
+
if (!data) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
...data,
|
|
82
|
+
has_next_page: checkHasAnotherPage(
|
|
83
|
+
data.comments,
|
|
84
|
+
data.comments_pagination?.next,
|
|
85
|
+
),
|
|
86
|
+
is_loading_next_page:
|
|
87
|
+
data?.comments_pagination?.loading_next_page ?? false,
|
|
88
|
+
loadNextPage,
|
|
89
|
+
};
|
|
90
|
+
}, [data, loadNextPage]);
|
|
91
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useFeedContext } from '../../contexts/StreamFeedContext';
|
|
2
|
+
import type { Feed, FeedState } from '@self';
|
|
3
|
+
import { useStateStore } from '@stream-io/state-store/react-bindings';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { useStableCallback } from '../internal';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A React hook that returns a reactive object containing the current activities,
|
|
9
|
+
* loading state and whether there is a next page to paginate to or not.
|
|
10
|
+
*/
|
|
11
|
+
export const useFeedActivities = (feedFromProps?: Feed) => {
|
|
12
|
+
const feedFromContext = useFeedContext();
|
|
13
|
+
const feed = feedFromProps ?? feedFromContext;
|
|
14
|
+
|
|
15
|
+
const data = useStateStore(feed?.state, selector);
|
|
16
|
+
|
|
17
|
+
const loadNextPage = useStableCallback(async () => {
|
|
18
|
+
if (!feed || !data?.has_next_page || data?.is_loading) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
await feed.getNextPage();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return useMemo(() => ({ ...data, loadNextPage }), [data, loadNextPage]);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const selector = ({
|
|
29
|
+
is_loading_activities,
|
|
30
|
+
next,
|
|
31
|
+
activities = [],
|
|
32
|
+
}: FeedState) => ({
|
|
33
|
+
is_loading: is_loading_activities,
|
|
34
|
+
has_next_page: typeof next !== 'undefined',
|
|
35
|
+
activities,
|
|
36
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Feed, FeedState } from '@self';
|
|
2
|
+
import { useFeedContext } from '../../contexts/StreamFeedContext';
|
|
3
|
+
import { useStateStore } from '@stream-io/state-store/react-bindings';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A React hook that returns a reactive object containing some often used
|
|
7
|
+
* metadata for a feed.
|
|
8
|
+
*/
|
|
9
|
+
export const useFeedMetadata = (feedFromProps?: Feed) => {
|
|
10
|
+
const feedFromContext = useFeedContext();
|
|
11
|
+
const feed = feedFromProps ?? feedFromContext;
|
|
12
|
+
|
|
13
|
+
return useStateStore(feed?.state, selector);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const selector = ({
|
|
17
|
+
follower_count = 0,
|
|
18
|
+
following_count = 0,
|
|
19
|
+
created_by,
|
|
20
|
+
created_at,
|
|
21
|
+
updated_at,
|
|
22
|
+
}: FeedState) => ({
|
|
23
|
+
created_by,
|
|
24
|
+
follower_count,
|
|
25
|
+
following_count,
|
|
26
|
+
created_at,
|
|
27
|
+
updated_at,
|
|
28
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { type Feed, type FeedState, checkHasAnotherPage } from '@self';
|
|
3
|
+
import { useStateStore } from '@stream-io/state-store/react-bindings';
|
|
4
|
+
import { useFeedContext } from '../../contexts/StreamFeedContext';
|
|
5
|
+
|
|
6
|
+
const selector = ({
|
|
7
|
+
follower_count,
|
|
8
|
+
followers,
|
|
9
|
+
followers_pagination,
|
|
10
|
+
}: FeedState) => ({
|
|
11
|
+
follower_count,
|
|
12
|
+
followers,
|
|
13
|
+
followers_pagination,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
type UseFollowersReturnType = ReturnType<typeof selector> & {
|
|
17
|
+
is_loading_next_page: boolean;
|
|
18
|
+
has_next_page: boolean;
|
|
19
|
+
loadNextPage: (
|
|
20
|
+
...options: Parameters<Feed['loadNextPageFollowers']>
|
|
21
|
+
) => Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function useFollowers(feed: Feed): UseFollowersReturnType;
|
|
25
|
+
export function useFollowers(feed?: Feed): UseFollowersReturnType | undefined;
|
|
26
|
+
export function useFollowers(feedFromProps?: Feed) {
|
|
27
|
+
const feedFromContext = useFeedContext();
|
|
28
|
+
const feed = feedFromProps ?? feedFromContext;
|
|
29
|
+
|
|
30
|
+
const data = useStateStore(feed?.state, selector);
|
|
31
|
+
|
|
32
|
+
const loadNextPage = useCallback(
|
|
33
|
+
(...options: Parameters<Feed['loadNextPageFollowers']>) =>
|
|
34
|
+
feed?.loadNextPageFollowers(...options),
|
|
35
|
+
[feed],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return useMemo(() => {
|
|
39
|
+
if (!data) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...data,
|
|
45
|
+
is_loading_next_page:
|
|
46
|
+
data.followers_pagination?.loading_next_page ?? false,
|
|
47
|
+
has_next_page: checkHasAnotherPage(
|
|
48
|
+
data.followers,
|
|
49
|
+
data.followers_pagination?.next,
|
|
50
|
+
),
|
|
51
|
+
loadNextPage,
|
|
52
|
+
};
|
|
53
|
+
}, [data, loadNextPage]);
|
|
54
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { type Feed, type FeedState, checkHasAnotherPage } from '@self';
|
|
3
|
+
import { useStateStore } from '@stream-io/state-store/react-bindings';
|
|
4
|
+
import { useFeedContext } from '../../contexts/StreamFeedContext';
|
|
5
|
+
|
|
6
|
+
const selector = ({
|
|
7
|
+
following_count,
|
|
8
|
+
following,
|
|
9
|
+
following_pagination,
|
|
10
|
+
}: FeedState) => ({
|
|
11
|
+
following_count,
|
|
12
|
+
following,
|
|
13
|
+
following_pagination,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
type UseFollowingReturnType = ReturnType<typeof selector> & {
|
|
17
|
+
is_loading_next_page: boolean;
|
|
18
|
+
has_next_page: boolean;
|
|
19
|
+
loadNextPage: (
|
|
20
|
+
...options: Parameters<Feed['loadNextPageFollowers']>
|
|
21
|
+
) => Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function useFollowing(feed: Feed): UseFollowingReturnType;
|
|
25
|
+
export function useFollowing(feed?: Feed): UseFollowingReturnType | undefined;
|
|
26
|
+
export function useFollowing(feedFromProps?: Feed) {
|
|
27
|
+
const feedFromContext = useFeedContext();
|
|
28
|
+
const feed = feedFromProps ?? feedFromContext;
|
|
29
|
+
|
|
30
|
+
const data = useStateStore(feed?.state, selector);
|
|
31
|
+
|
|
32
|
+
const loadNextPage = useCallback(
|
|
33
|
+
(...options: Parameters<Feed['loadNextPageFollowing']>) =>
|
|
34
|
+
feed?.loadNextPageFollowing(...options),
|
|
35
|
+
[feed],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return useMemo(() => {
|
|
39
|
+
if (!data) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...data,
|
|
45
|
+
is_loading_next_page:
|
|
46
|
+
data.following_pagination?.loading_next_page ?? false,
|
|
47
|
+
has_next_page: checkHasAnotherPage(
|
|
48
|
+
data.following,
|
|
49
|
+
data.following_pagination?.next,
|
|
50
|
+
),
|
|
51
|
+
loadNextPage,
|
|
52
|
+
};
|
|
53
|
+
}, [data, loadNextPage]);
|
|
54
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useFeedContext } from '../../contexts/StreamFeedContext';
|
|
2
|
+
import { useNotificationStatus } from './useNotificationStatus';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import type { AggregatedActivityResponse, Feed } from '@self';
|
|
5
|
+
|
|
6
|
+
export const useIsAggregatedActivityRead = ({
|
|
7
|
+
feed: feedFromProps,
|
|
8
|
+
aggregatedActivity,
|
|
9
|
+
}: {
|
|
10
|
+
feed?: Feed;
|
|
11
|
+
aggregatedActivity: AggregatedActivityResponse;
|
|
12
|
+
}) => {
|
|
13
|
+
const feedFromContext = useFeedContext();
|
|
14
|
+
const feed = feedFromProps ?? feedFromContext;
|
|
15
|
+
|
|
16
|
+
const { read_activities: readActivities /* last_read_at: lastReadAt */ } =
|
|
17
|
+
useNotificationStatus(feed) ?? {};
|
|
18
|
+
|
|
19
|
+
const group = aggregatedActivity.group;
|
|
20
|
+
|
|
21
|
+
return useMemo(
|
|
22
|
+
() =>
|
|
23
|
+
// FIXME: This part of the condition does not work as marking individual groups as read also updates the last_read_at. Should be uncommented once it's fixed on the backend.
|
|
24
|
+
// (lastReadAt &&
|
|
25
|
+
// aggregatedActivity.updated_at.getTime() <= lastReadAt.getTime()) ||
|
|
26
|
+
(readActivities ?? []).includes(group),
|
|
27
|
+
[readActivities, group],
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useFeedContext } from '../../contexts/StreamFeedContext';
|
|
2
|
+
import { useNotificationStatus } from './useNotificationStatus';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import type { AggregatedActivityResponse, Feed } from '@self';
|
|
5
|
+
|
|
6
|
+
export const useIsAggregatedActivitySeen = ({
|
|
7
|
+
feed: feedFromProps,
|
|
8
|
+
aggregatedActivity,
|
|
9
|
+
}: {
|
|
10
|
+
feed?: Feed;
|
|
11
|
+
aggregatedActivity: AggregatedActivityResponse;
|
|
12
|
+
}) => {
|
|
13
|
+
const feedFromContext = useFeedContext();
|
|
14
|
+
const feed = feedFromProps ?? feedFromContext;
|
|
15
|
+
|
|
16
|
+
const { seen_activities: seenActivities, last_seen_at: lastSeenAt } =
|
|
17
|
+
useNotificationStatus(feed) ?? {};
|
|
18
|
+
|
|
19
|
+
const group = aggregatedActivity.group;
|
|
20
|
+
|
|
21
|
+
return useMemo(
|
|
22
|
+
() =>
|
|
23
|
+
(lastSeenAt &&
|
|
24
|
+
aggregatedActivity.updated_at.getTime() < lastSeenAt.getTime()) ||
|
|
25
|
+
(seenActivities ?? []).includes(group),
|
|
26
|
+
[lastSeenAt, aggregatedActivity.updated_at, seenActivities, group],
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Feed, FeedState, NotificationStatusResponse } from '@self';
|
|
2
|
+
import { useStateStore } from '@stream-io/state-store/react-bindings';
|
|
3
|
+
import { useFeedContext } from '../../contexts/StreamFeedContext';
|
|
4
|
+
|
|
5
|
+
const selector = ({ notification_status }: FeedState) =>
|
|
6
|
+
({
|
|
7
|
+
unread: notification_status?.unread ?? 0,
|
|
8
|
+
unseen: notification_status?.unseen ?? 0,
|
|
9
|
+
last_read_at: notification_status?.last_read_at,
|
|
10
|
+
last_seen_at: notification_status?.last_seen_at,
|
|
11
|
+
read_activities: notification_status?.read_activities,
|
|
12
|
+
seen_activities: notification_status?.seen_activities,
|
|
13
|
+
}) satisfies NotificationStatusResponse;
|
|
14
|
+
|
|
15
|
+
type UseNotificationStatusReturnType = ReturnType<typeof selector>;
|
|
16
|
+
|
|
17
|
+
export function useNotificationStatus(
|
|
18
|
+
feed: Feed,
|
|
19
|
+
): UseNotificationStatusReturnType;
|
|
20
|
+
export function useNotificationStatus(
|
|
21
|
+
feed?: Feed,
|
|
22
|
+
): UseNotificationStatusReturnType | undefined;
|
|
23
|
+
export function useNotificationStatus(feedFromProps?: Feed) {
|
|
24
|
+
const feedFromContext = useFeedContext();
|
|
25
|
+
const feed = feedFromProps ?? feedFromContext;
|
|
26
|
+
|
|
27
|
+
return useStateStore(feed?.state, selector);
|
|
28
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { type Feed, type FeedState, FeedOwnCapability } from '@self';
|
|
3
|
+
import { useStateStore } from '@stream-io/state-store/react-bindings';
|
|
4
|
+
import { useFeedContext } from '../../contexts/StreamFeedContext';
|
|
5
|
+
|
|
6
|
+
const stableEmptyArray: readonly FeedOwnCapability[] = [];
|
|
7
|
+
|
|
8
|
+
const selector = (currentState: FeedState) => ({
|
|
9
|
+
oc: currentState.own_capabilities ?? stableEmptyArray,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
type KebabToSnakeCase<S extends string> = S extends `${infer T}-${infer U}`
|
|
13
|
+
? `${T}_${KebabToSnakeCase<U>}`
|
|
14
|
+
: S;
|
|
15
|
+
|
|
16
|
+
export const useOwnCapabilities = (feedFromProps?: Feed) => {
|
|
17
|
+
const feedFromContext = useFeedContext();
|
|
18
|
+
const feed = feedFromProps ?? feedFromContext;
|
|
19
|
+
|
|
20
|
+
const { oc = stableEmptyArray } = useStateStore(feed?.state, selector) ?? {};
|
|
21
|
+
|
|
22
|
+
return useMemo(
|
|
23
|
+
() =>
|
|
24
|
+
({
|
|
25
|
+
can_add_activity: oc.indexOf(FeedOwnCapability.ADD_ACTIVITY) > -1,
|
|
26
|
+
can_add_activity_reaction:
|
|
27
|
+
oc.indexOf(FeedOwnCapability.ADD_ACTIVITY_REACTION) > -1,
|
|
28
|
+
can_add_comment: oc.indexOf(FeedOwnCapability.ADD_COMMENT) > -1,
|
|
29
|
+
can_add_comment_reaction:
|
|
30
|
+
oc.indexOf(FeedOwnCapability.ADD_COMMENT_REACTION) > -1,
|
|
31
|
+
can_bookmark_activity:
|
|
32
|
+
oc.indexOf(FeedOwnCapability.BOOKMARK_ACTIVITY) > -1,
|
|
33
|
+
can_create_feed: oc.indexOf(FeedOwnCapability.CREATE_FEED) > -1,
|
|
34
|
+
can_delete_bookmark: oc.indexOf(FeedOwnCapability.DELETE_BOOKMARK) > -1,
|
|
35
|
+
can_delete_comment: oc.indexOf(FeedOwnCapability.DELETE_COMMENT) > -1,
|
|
36
|
+
can_delete_feed: oc.indexOf(FeedOwnCapability.DELETE_FEED) > -1,
|
|
37
|
+
can_edit_bookmark: oc.indexOf(FeedOwnCapability.EDIT_BOOKMARK) > -1,
|
|
38
|
+
can_follow: oc.indexOf(FeedOwnCapability.FOLLOW) > -1,
|
|
39
|
+
can_remove_activity: oc.indexOf(FeedOwnCapability.REMOVE_ACTIVITY) > -1,
|
|
40
|
+
can_remove_activity_reaction:
|
|
41
|
+
oc.indexOf(FeedOwnCapability.REMOVE_ACTIVITY_REACTION) > -1,
|
|
42
|
+
can_remove_comment_reaction:
|
|
43
|
+
oc.indexOf(FeedOwnCapability.REMOVE_COMMENT_REACTION) > -1,
|
|
44
|
+
can_unfollow: oc.indexOf(FeedOwnCapability.UNFOLLOW) > -1,
|
|
45
|
+
can_update_feed: oc.indexOf(FeedOwnCapability.UPDATE_FEED) > -1,
|
|
46
|
+
can_invite_feed: oc.indexOf(FeedOwnCapability.INVITE_FEED) > -1,
|
|
47
|
+
can_join_feed: oc.indexOf(FeedOwnCapability.JOIN_FEED) > -1,
|
|
48
|
+
can_leave_feed: oc.indexOf(FeedOwnCapability.LEAVE_FEED) > -1,
|
|
49
|
+
can_manage_feed_group:
|
|
50
|
+
oc.indexOf(FeedOwnCapability.MANAGE_FEED_GROUP) > -1,
|
|
51
|
+
can_mark_activity: oc.indexOf(FeedOwnCapability.MARK_ACTIVITY) > -1,
|
|
52
|
+
can_pin_activity: oc.indexOf(FeedOwnCapability.PIN_ACTIVITY) > -1,
|
|
53
|
+
can_query_feed_members:
|
|
54
|
+
oc.indexOf(FeedOwnCapability.QUERY_FEED_MEMBERS) > -1,
|
|
55
|
+
can_query_follows: oc.indexOf(FeedOwnCapability.QUERY_FOLLOWS) > -1,
|
|
56
|
+
can_read_activities: oc.indexOf(FeedOwnCapability.READ_ACTIVITIES) > -1,
|
|
57
|
+
can_read_feed: oc.indexOf(FeedOwnCapability.READ_FEED) > -1,
|
|
58
|
+
can_update_activity: oc.indexOf(FeedOwnCapability.UPDATE_ACTIVITY) > -1,
|
|
59
|
+
can_update_comment: oc.indexOf(FeedOwnCapability.UPDATE_COMMENT) > -1,
|
|
60
|
+
can_update_feed_followers:
|
|
61
|
+
oc.indexOf(FeedOwnCapability.UPDATE_FEED_FOLLOWERS) > -1,
|
|
62
|
+
can_update_feed_members:
|
|
63
|
+
oc.indexOf(FeedOwnCapability.UPDATE_FEED_MEMBERS) > -1,
|
|
64
|
+
}) satisfies Record<
|
|
65
|
+
`can_${KebabToSnakeCase<(typeof FeedOwnCapability)[keyof typeof FeedOwnCapability]>}`,
|
|
66
|
+
boolean
|
|
67
|
+
>,
|
|
68
|
+
[oc],
|
|
69
|
+
);
|
|
70
|
+
};
|