Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ command:
dio: ^5.9.0
equatable: ^2.0.5
flutter_state_notifier: ^1.0.0
flutter_svg: ^2.2.0
freezed_annotation: ^3.0.0
get_it: ^8.0.3
google_fonts: ^6.3.0
injectable: ^2.5.1
http: ^1.1.0
intl: ">=0.18.1 <=0.21.0"
jiffy: ^6.4.3
json_annotation: ^4.9.0
meta: ^1.9.1
retrofit: ^4.6.0
Expand All @@ -36,6 +40,7 @@ command:
state_notifier: ^1.0.0
uuid: ^4.5.1

# TODO Replace with hosted version when published
stream_core:
git:
url: https://github.com/GetStream/stream-core-flutter.git
Expand All @@ -47,6 +52,7 @@ command:
auto_route_generator: ^10.0.0
build_runner: ^2.4.15
freezed: ^3.0.0
injectable_generator: ^2.7.0
json_serializable: ^6.9.5
mocktail: ^1.0.4
retrofit_generator: ^9.6.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:freezed_annotation/freezed_annotation.dart';

import '../../../stream_feeds.dart' as api;

part 'activity_update_comment_request.freezed.dart';

/// A request for updating a comment to an activity.
@freezed
class ActivityUpdateCommentRequest with _$ActivityUpdateCommentRequest {
const ActivityUpdateCommentRequest({
this.comment,
this.custom,
this.skipPush,
});

@override
final String? comment;

@override
final Map<String, Object?>? custom;

@override
final bool? skipPush;
}

extension ActivityUpdateCommentRequestMapper on ActivityUpdateCommentRequest {
api.UpdateCommentRequest toRequest() => api.UpdateCommentRequest(
comment: comment,
custom: custom,
skipPush: skipPush,
);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ extension ThreadedCommentDataMutations on ThreadedCommentData {
ThreadedCommentData reply,
Comparator<CommentsSortDataFields> comparator,
) {
final updatedReplies = replies?.sortedUpsert(
final currentReplies = replies ?? [];
final updatedReplies = currentReplies.sortedUpsert(
reply,
key: (it) => it.id,
compare: comparator,
Expand All @@ -315,7 +316,10 @@ extension ThreadedCommentDataMutations on ThreadedCommentData {
/// @param comment The reply comment to remove.
/// @return A new [ThreadedCommentData] instance with the updated replies and reply count.
ThreadedCommentData removeReply(ThreadedCommentData reply) {
final updatedReplies = replies?.where((it) => it.id != reply.id).toList();
final currentReplies = replies ?? [];
final updatedReplies = currentReplies.where((it) {
return it.id != reply.id;
}).toList();

return copyWith(
replies: updatedReplies,
Expand All @@ -331,7 +335,8 @@ extension ThreadedCommentDataMutations on ThreadedCommentData {
ThreadedCommentData reply,
Comparator<CommentsSortDataFields> comparator,
) {
final updatedReplies = replies?.sortedUpsert(
final currentReplies = replies ?? [];
final updatedReplies = currentReplies.sortedUpsert(
reply,
key: (it) => it.id,
compare: comparator,
Expand Down
6 changes: 4 additions & 2 deletions packages/stream_feeds/lib/src/state/activity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import '../models/poll_data.dart';
import '../models/poll_option_data.dart';
import '../models/poll_vote_data.dart';
import '../models/request/activity_add_comment_request.dart';
import '../models/request/activity_update_comment_request.dart';
import '../models/threaded_comment_data.dart';
import '../repository/activities_repository.dart';
import '../repository/comments_repository.dart';
Expand Down Expand Up @@ -196,9 +197,10 @@ class Activity with Disposable {
/// Returns a [Result] containing the updated [CommentData] or an error.
Future<Result<CommentData>> updateComment(
String commentId,
api.UpdateCommentRequest request,
ActivityUpdateCommentRequest request,
) async {
final result = await commentsRepository.updateComment(commentId, request);
final result =
await commentsRepository.updateComment(commentId, request.toRequest());

result.onSuccess(_commentsList.notifier.onCommentUpdated);

Expand Down
16 changes: 15 additions & 1 deletion packages/stream_feeds/lib/src/state/activity_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:state_notifier/state_notifier.dart';
import 'package:stream_core/stream_core.dart';

import '../models/activity_data.dart';
import '../models/pagination_data.dart';
import '../models/poll_data.dart';
import '../models/poll_vote_data.dart';
import '../models/threaded_comment_data.dart';
Expand Down Expand Up @@ -31,7 +32,10 @@ class ActivityStateNotifier extends StateNotifier<ActivityState> {
void _setupCommentListSynchronization() {
_removeCommentListListener = commentList.addListener((commentListState) {
// Synchronize state with the comment list state
state = state.copyWith(comments: commentListState.comments);
state = state.copyWith(
comments: commentListState.comments,
commentsPagination: commentListState.pagination,
);
});
}

Expand Down Expand Up @@ -174,6 +178,7 @@ class ActivityState with _$ActivityState {
const ActivityState({
this.activity,
this.comments = const [],
this.commentsPagination,
this.poll,
});

Expand All @@ -190,6 +195,15 @@ class ActivityState with _$ActivityState {
@override
final List<ThreadedCommentData> comments;

/// Pagination information for [comments].
@override
final PaginationData? commentsPagination;

/// Indicates whether there are more [comments] available to load.
///
/// Returns true if there is a next page available for pagination.
bool get canLoadMoreComments => commentsPagination?.next != null;

/// The poll associated with this activity, if any.
///
/// Contains poll information including options, votes, and poll state.
Expand Down
13 changes: 11 additions & 2 deletions packages/stream_feeds/lib/src/state/activity_state.freezed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class BookmarkFolderList extends Disposable {
/// Queries the initial list of bookmark folders based on the provided [BookmarkFoldersQuery].
///
/// Returns a [Result] containing a list of [BookmarkFolderData] or an error.
Future<Result<List<BookmarkFolderData>>> get() => _queryBookmarkFolders(query);
Future<Result<List<BookmarkFolderData>>> get() =>
_queryBookmarkFolders(query);

/// Loads more bookmark folders based on the current pagination state.
///
Expand Down
1 change: 1 addition & 0 deletions packages/stream_feeds/lib/src/state/feed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Feed with Disposable {
_eventsSubscription = eventsEmitter.listen(handler.handleEvent);
}

FeedId get fid => query.fid;
final FeedQuery query;
final String currentUserId;

Expand Down
7 changes: 7 additions & 0 deletions packages/stream_feeds/lib/stream_feeds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export 'src/models/feed_id.dart';
export 'src/models/feed_input_data.dart';
export 'src/models/feed_member_request_data.dart';
export 'src/models/poll_data.dart';
export 'src/models/request/activity_add_comment_request.dart'
show ActivityAddCommentRequest;
export 'src/models/request/activity_update_comment_request.dart'
show ActivityUpdateCommentRequest;
export 'src/models/threaded_comment_data.dart';
export 'src/models/user_data.dart';
export 'src/state/activity.dart';
export 'src/state/feed.dart';
export 'src/state/feed_state.dart';
export 'src/state/query/feed_query.dart';
1 change: 0 additions & 1 deletion packages/stream_feeds/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dependencies:
retrofit: ^4.6.0
rxdart: ^0.28.0
state_notifier: ^1.0.0
# TODO Replace with hosted version when published
stream_core:
git:
url: https://github.com/GetStream/stream-core-flutter.git
Expand Down
5 changes: 5 additions & 0 deletions sample_app/assets/images/app_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading