refactor(llc): refactor client and add impl#8
Merged
Conversation
This commit introduces client-side state management for all list types: - `ActivityList` - `ActivityCommentList` - `ActivityReactionList` - `BookmarkList` - `BookmarkFolderList` - `CommentReplyList` - `CommentReactionList` - `FollowList` - `PollList` - `PollVoteList` It also implements the `Activity` state object. Each list type and the `Activity` object now have: - A dedicated state notifier (e.g., `ActivityListStateNotifier`). - A corresponding state class (e.g., `ActivityListState`) using `freezed`. - Event handlers for real-time updates via WebSockets (e.g., `ActivityListEventHandler`). Key changes: - `FeedsClientImpl`: - Instantiates and returns the new stateful list objects. - Passes necessary repositories and event emitters to these objects. - Adds `pollAnswerCastedFeedEventResolver` and `pollAnswerRemovedFeedEventResolver` to WebSocket event resolvers. - Corrects user image field in `_authenticateUser`. - Handles `ClientException` for anonymous user connection attempts. - State notifiers: - Manage the data (e.g., activities, comments) and pagination state. - Provide methods to update the state based on API responses and WebSocket events. - Utilize `QueryConfiguration` to store and use filter and sort parameters. - State classes: - Define the structure of the observable state (e.g., list of items, pagination data). - Include a `canLoadMore` getter. - Event handlers: - Process specific WebSocket events relevant to their list type. - Call appropriate methods on the state notifier to update the state. - Model updates: - `ThreadedCommentData`: Added mutation methods for reactions and replies, and a `setCommentData` method. - `ActivitiesSortField`: `createdAt` now uses `data.createdAt`, `popularity` uses `data.popularity`. - `ReactionGroupData`: Improved logic in `decrement` and `increment` methods. - `PollData`: Added `ownVotesAndAnswers`, `ownVotes`, `ownAnswers`, and `latestVotes` getters. Added mutation methods for options and answers. - `PollVoteData`: `isAnswer` is now a getter based on `answerText`. - Repository updates: - `CommentsRepository`: `deleteComment` now accepts an optional `hardDelete` parameter. - `PollsRepository`: Removed `userId` parameter from `deletePoll`, `getPoll`, `deletePollOption`, `getPollOption`, and `deletePollVote`. - New event resolvers: - `pollAnswerCastedFeedEventResolver`: Resolves `PollAnswerCastedFeedEvent` from `PollVoteCastedFeedEvent` or `PollVoteChangedFeedEvent`. - `pollAnswerRemovedFeedEventResolver`: Resolves `PollAnswerRemovedFeedEvent` from `PollVoteRemovedFeedEvent`. This provides a reactive way to interact with lists of data from Stream Feeds, automatically handling updates and pagination.
The `event_resolvers` directory and its contents have been moved to a new directory named `resolvers`. This change aims to improve the project structure and clarity. Imports in affected files have been updated to reflect the new location of the resolver utilities.
The FeedsStateNotifier class was identical to StateNotifier and thus redundant. This commit removes FeedsStateNotifier and updates ActivityReactionListStateNotifier to directly extend StateNotifier.
The `collection` package was being imported but not used in several state management files. This commit removes those unnecessary imports.
This commit introduces significant improvements to the script used for generating the Dart client for Stream Feeds. Key changes: - **Configuration:** Moved the `CHAT_DIR` configuration to the top of the script for easier modification by developers. - **Path Handling:** Implemented more robust path handling using `SCRIPT_DIR` and `REPO_ROOT` to make the script less dependent on absolute paths. - **Validation:** Added checks for the existence of `CHAT_DIR`, `renamed-models.json`, and the presence of `go` and `dart` in the system PATH. - **Clarity:** Added `echo` statements to provide better feedback to the user during the generation process. - **Sed Portability:** Replaced `sed -i ''` with a more portable `sed_inplace` function that works on both macOS and Linux. - **Scoped Build & Format:** Limited `build_runner` and `dart format` to only run on the `stream_feeds` package, improving efficiency. - **Output Directory:** Ensured the output directory for generated code is created if it doesn't exist. - **Error Handling:** Utilized `set -euo pipefail` for better script error handling. - **Melos Integration:** Added a new melos script `gen:feeds` to trigger this generation script. The script now performs the following steps: 1. Generates the OpenAPI spec and Dart client from the chat repository. 2. Applies post-generation fixes (e.g., removing duplicate fields in generated models). 3. Runs `build_runner` specifically for the `stream_feeds` package. 4. Formats the generated code within the `stream_feeds` package.
The User.imageUrl field has been renamed to User.image to better reflect its purpose and potentially support non-URL image sources in the future. This commit updates the sample_app to use the new field name.
This script is no longer needed as the OpenAPI client generation process has been consolidated into the `chat-manager` tool within the `stream-chat-go` repository.
renefloor
reviewed
Aug 29, 2025
melos.yaml
Outdated
| git: | ||
| url: https://github.com/GetStream/stream-core-flutter.git | ||
| path: packages/stream_core | ||
| ref: main |
Collaborator
There was a problem hiding this comment.
Using a branch for ref is not so nice. You have to delete your pubspec.lock to update the package when there is a new version on that branch because the lock file refers to a specific commit.
Better to use commit hash, or maybe even add pre-release tags, but I would go for the hash.
scripts/generate.sh
Outdated
| # ========================= | ||
| CHAT_DIR="/ABSOLUTE/PATH/TO/YOUR/chat/repo" | ||
| if [[ "$CHAT_DIR" == "/ABSOLUTE/PATH/TO/YOUR/chat/repo" ]]; then | ||
| echo "❌ Please edit scripts/gen-feeds.sh and set CHAT_DIR to your local chat repo path" |
Collaborator
There was a problem hiding this comment.
Do you have an example of the scripts/gen-feeds.sh?
Good to add some explanation to the readme in the root of the repo.
Member
Author
There was a problem hiding this comment.
It was a typo, it should be scripts/generate.sh. I additionally added a melos script to call it directly.
melos gen:feeds
This commit updates the `stream_core` dependency in both `melos.yaml` and `packages/stream_feeds/pubspec.yaml` to point to a specific commit hash (`3b59846b89070fdd542945dbc1228a0a472e9b37`) instead of the `main` branch. This ensures that the project uses a consistent and tested version of the `stream_core` package.
renefloor
approved these changes
Aug 29, 2025
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.
No description provided.