Skip to content

Conversation

@xsahil03x
Copy link
Member

Submit a pull request

Closes FLU-312

Description of the pull request

This PR introduces the ability to submit feedback for activities, such as marking an activity as hidden. It adds an activityFeedback method to the Activity and Feed classes and handles real-time state updates via WebSocket events.

Key changes:

  • API: Added activityFeedback method to ActivitiesRepository, Activity, and Feed to allow submitting feedback (e.g., hide/unhide).
  • State Management: Implemented onActivityHidden handlers in ActivityState, ActivityListState, and FeedState to update the hidden status of activities in response to ActivityFeedbackEvent from WebSockets.
  • Event Handling: ActivityEventHandler, ActivityListEventHandler, and FeedEventHandler now process ActivityFeedbackEvent to trigger state updates, ensuring the UI reflects whether an activity is hidden.
  • Testing:
        - Introduced a new suite of test utilities (BaseTester, ActivityTester, FeedTester, ActivityListTester, ApiMockerMixin) to streamline testing of stateful objects with API and WebSocket interactions.
        - Added comprehensive tests for the new activity feedback functionality, covering both API calls and real-time event handling.
  • Refactor: Minor refactoring in test helpers (fakes.dart) to improve consistency.

This PR regenerates the client-side API models and endpoints, incorporating numerous additions and breaking changes from a recent backend API update.

### Breaking Changes
- **`queryFollowSuggestions`:** The method signature and return type have changed. It now returns a `Result<List<FeedSuggestionData>>` instead of `Result<List<FeedData>>`. The new `FeedSuggestionData` model includes additional metadata like `reason`, `recommendationScore`, and `algorithmScores`.
- **`FeedsReactionData.id`:** The logic for generating a reaction's unique ID has been updated to correctly include the `commentId` when present, ensuring proper identification for comment reactions.

### Features
- **Collections API:** Added full support for the Collections API, including new request/response models and endpoints for creating, reading, updating, and deleting collections (`CreateCollections`, `ReadCollections`, `UpdateCollections`, `DeleteCollections`).
- **`ActivityData` Enhancements:** Added `hidden` and `preview` boolean fields to the `ActivityData` model to support content hiding and previewing functionalities.
- **`FeedSuggestionData` Model:** Introduced a new `FeedSuggestionData` model to encapsulate feed suggestions, providing richer context with algorithmic scores and reasons.
- **Moderation and Deletion Reasons:** Added an optional `reason` field to various deletion and moderation requests (`DeleteActivityRequest`, `DeleteCommentRequest`, `DeleteReactionRequest`, `DeleteUserRequest`, `BlockActionRequest`, `ShadowBlockActionRequest`) to provide context for moderation actions.

### Other Key Changes
- **API Model Updates:**
  - `ActivityRequest` and `UpdateActivityRequest` now include `collectionRefs`, `restrictReplies`, and `skipEnrichUrl`.
  - `ActivityResponse` now includes `collections`, `moderationAction`, `preview`, `hidden`, and `restrictReplies`.
  - `ChannelMemberResponse` and related models have been significantly expanded with new fields like `banned`, `createdAt`, `custom`, `role`, and more.
  - `ChannelResponse` and `Channel` models now include `filterTags`.
  - Introduced `ActivityFeedbackEvent` for real-time feedback updates.
  - Deprecated `muteUser` and `report` from `ActivityFeedbackRequest`.
- **Endpoint and Request Adjustments:**
  - Made `addCommentRequest` in the `addComment` endpoint nullable.
  - Removed the deprecated `activitySelectorOptions` from `FeedQuery` and `GetOrCreateFeedRequest`.
- **Testing:** Added tests for the new `queryFollowSuggestions` functionality to validate the handling of `FeedSuggestionData`.
This commit pins the `retrofit` dependency to a version range of `>=4.6.0 <=4.9.0`.

This change is necessary to avoid a breaking change introduced in `retrofit` version 4.10.0. The version constraint is applied in the root `melos.yaml` and the `packages/stream_feeds/pubspec.yaml` file.
This commit introduces the ability to submit feedback for activities, such as marking an activity as hidden. It adds an `activityFeedback` method to the `Activity` and `Feed` classes and handles real-time state updates via WebSocket events.

Key changes:
- **API**: Added `activityFeedback` method to `ActivitiesRepository`, `Activity`, and `Feed` to allow submitting feedback (e.g., hide/unhide).
- **State Management**: Implemented `onActivityHidden` handlers in `ActivityState`, `ActivityListState`, and `FeedState` to update the `hidden` status of activities in response to `ActivityFeedbackEvent` from WebSockets.
- **Event Handling**: `ActivityEventHandler`, `ActivityListEventHandler`, and `FeedEventHandler` now process `ActivityFeedbackEvent` to trigger state updates, ensuring the UI reflects whether an activity is hidden.
- **Testing**:
    - Introduced a new suite of test utilities (`BaseTester`, `ActivityTester`, `FeedTester`, `ActivityListTester`, `ApiMockerMixin`) to streamline testing of stateful objects with API and WebSocket interactions.
    - Added comprehensive tests for the new activity feedback functionality, covering both API calls and real-time event handling.
- **Refactor**: Minor refactoring in test helpers (`fakes.dart`) to improve consistency.
@xsahil03x xsahil03x requested a review from a team as a code owner November 25, 2025 00:53
@xsahil03x xsahil03x requested review from Copilot and removed request for a team November 25, 2025 00:54
Copilot finished reviewing on behalf of xsahil03x November 25, 2025 00:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces activity feedback support to the Stream Feeds SDK, enabling users to submit feedback for activities (e.g., marking activities as hidden/unhidden) with real-time WebSocket event handling. The implementation follows established architectural patterns and includes a comprehensive test infrastructure to streamline testing of stateful objects with API and WebSocket interactions.

Key Changes:

  • Added activityFeedback API method to Activity, Feed, and ActivitiesRepository classes for submitting feedback
  • Implemented real-time state updates via onActivityHidden handlers in ActivityState, ActivityListState, and FeedState to reflect hidden status changes from WebSocket events
  • Created a new test utilities framework (BaseTester, ActivityTester, FeedTester, ActivityListTester, ApiMockerMixin) to simplify testing of stateful objects with mocked APIs and WebSocket interactions

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/stream_feeds/lib/src/repository/activities_repository.dart Added activityFeedback method to submit activity feedback via API
packages/stream_feeds/lib/src/state/activity.dart Added activityFeedback method and integrated ActivityEventHandler with currentUserId and activityId
packages/stream_feeds/lib/src/state/feed.dart Added activityFeedback method and passed currentUserId to FeedEventHandler
packages/stream_feeds/lib/src/state/activity_list.dart Passed currentUserId to ActivityListEventHandler for event filtering
packages/stream_feeds/lib/src/state/activity_state.dart Added onActivityHidden handler to update activity hidden status
packages/stream_feeds/lib/src/state/feed_state.dart Added onActivityHidden handler to update hidden status in both activities and pinned activities lists
packages/stream_feeds/lib/src/state/activity_list_state.dart Added onActivityHidden handler to update activity hidden status in list
packages/stream_feeds/lib/src/state/event/activity_event_handler.dart Added handling for ActivityFeedbackEvent with user and activity ID filtering
packages/stream_feeds/lib/src/state/event/feed_event_handler.dart Added handling for ActivityFeedbackEvent with user ID filtering
packages/stream_feeds/lib/src/state/event/activity_list_event_handler.dart Added handling for ActivityFeedbackEvent with user ID filtering
packages/stream_feeds/test/test_utils/testers/base_tester.dart New test infrastructure providing common functionality for testers with WebSocket support
packages/stream_feeds/test/test_utils/testers/api_mocker_mixin.dart New mixin for mocking and verifying API calls in tests
packages/stream_feeds/test/test_utils/testers/activity_tester.dart New test helper for activity operations with WebSocket support
packages/stream_feeds/test/test_utils/testers/feed_tester.dart New test helper for feed operations with WebSocket support
packages/stream_feeds/test/test_utils/testers/activity_list_tester.dart New test helper for activity list operations with WebSocket support
packages/stream_feeds/test/test_utils/fakes.dart Refactored to extract createDefaultActivityResponse and added createDefaultActivityFeedbackResponse
packages/stream_feeds/test/test_utils/event_types.dart Added activityFeedback event type constant
packages/stream_feeds/test/state/activity_test.dart Added comprehensive tests for activity feedback API and events
packages/stream_feeds/test/state/feed_test.dart Added comprehensive tests for feed activity feedback API and events
packages/stream_feeds/test/state/activity_list_test.dart Added comprehensive tests for activity list feedback events
packages/stream_feeds/CHANGELOG.md Documented the new activityFeedback feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 96.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.04%. Comparing base (5649be7) to head (d01f547).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ackages/stream_feeds/lib/src/state/feed_state.dart 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #58      +/-   ##
==========================================
+ Coverage   43.42%   45.04%   +1.61%     
==========================================
  Files         121      121              
  Lines        3675     3730      +55     
==========================================
+ Hits         1596     1680      +84     
+ Misses       2079     2050      -29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from feat/update-generated-code to main November 25, 2025 11:36
…k-operation

# Conflicts:
#	packages/stream_feeds/CHANGELOG.md
#	packages/stream_feeds/test/state/feed_test.dart
#	packages/stream_feeds/test/test_utils/fakes.dart
@xsahil03x xsahil03x enabled auto-merge (squash) November 25, 2025 13:19
@xsahil03x xsahil03x merged commit e705228 into main Nov 25, 2025
8 checks passed
@xsahil03x xsahil03x deleted the feat/activity-feedback-operation branch November 25, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants