Skip to content

Commit 831f5fd

Browse files
xsahil03xrenefloor
andauthored
feat(samples): update sample app (#10)
Co-authored-by: Rene Floor <rene.floor@getstream.io>
1 parent 1932eeb commit 831f5fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2969
-451
lines changed

melos.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ command:
2424
dio: ^5.9.0
2525
equatable: ^2.0.5
2626
flutter_state_notifier: ^1.0.0
27+
flutter_svg: ^2.2.0
2728
freezed_annotation: ^3.0.0
2829
get_it: ^8.0.3
30+
google_fonts: ^6.3.0
31+
injectable: ^2.5.1
2932
http: ^1.1.0
3033
intl: ">=0.18.1 <=0.21.0"
34+
jiffy: ^6.4.3
3135
json_annotation: ^4.9.0
3236
meta: ^1.9.1
3337
retrofit: ^4.6.0
@@ -36,6 +40,7 @@ command:
3640
state_notifier: ^1.0.0
3741
uuid: ^4.5.1
3842

43+
# TODO Replace with hosted version when published
3944
stream_core:
4045
git:
4146
url: https://github.com/GetStream/stream-core-flutter.git
@@ -47,6 +52,7 @@ command:
4752
auto_route_generator: ^10.0.0
4853
build_runner: ^2.4.15
4954
freezed: ^3.0.0
55+
injectable_generator: ^2.7.0
5056
json_serializable: ^6.9.5
5157
mocktail: ^1.0.4
5258
retrofit_generator: ^9.6.0
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import 'package:freezed_annotation/freezed_annotation.dart';
2+
3+
import '../../../stream_feeds.dart' as api;
4+
5+
part 'activity_update_comment_request.freezed.dart';
6+
7+
/// A request for updating a comment to an activity.
8+
@freezed
9+
class ActivityUpdateCommentRequest with _$ActivityUpdateCommentRequest {
10+
const ActivityUpdateCommentRequest({
11+
this.comment,
12+
this.custom,
13+
this.skipPush,
14+
});
15+
16+
@override
17+
final String? comment;
18+
19+
@override
20+
final Map<String, Object?>? custom;
21+
22+
@override
23+
final bool? skipPush;
24+
}
25+
26+
extension ActivityUpdateCommentRequestMapper on ActivityUpdateCommentRequest {
27+
api.UpdateCommentRequest toRequest() => api.UpdateCommentRequest(
28+
comment: comment,
29+
custom: custom,
30+
skipPush: skipPush,
31+
);
32+
}

packages/stream_feeds/lib/src/models/request/activity_update_comment_request.freezed.dart

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/stream_feeds/lib/src/models/threaded_comment_data.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ extension ThreadedCommentDataMutations on ThreadedCommentData {
298298
ThreadedCommentData reply,
299299
Comparator<CommentsSortDataFields> comparator,
300300
) {
301-
final updatedReplies = replies?.sortedUpsert(
301+
final currentReplies = replies ?? [];
302+
final updatedReplies = currentReplies.sortedUpsert(
302303
reply,
303304
key: (it) => it.id,
304305
compare: comparator,
@@ -315,7 +316,10 @@ extension ThreadedCommentDataMutations on ThreadedCommentData {
315316
/// @param comment The reply comment to remove.
316317
/// @return A new [ThreadedCommentData] instance with the updated replies and reply count.
317318
ThreadedCommentData removeReply(ThreadedCommentData reply) {
318-
final updatedReplies = replies?.where((it) => it.id != reply.id).toList();
319+
final currentReplies = replies ?? [];
320+
final updatedReplies = currentReplies.where((it) {
321+
return it.id != reply.id;
322+
}).toList();
319323

320324
return copyWith(
321325
replies: updatedReplies,
@@ -331,7 +335,8 @@ extension ThreadedCommentDataMutations on ThreadedCommentData {
331335
ThreadedCommentData reply,
332336
Comparator<CommentsSortDataFields> comparator,
333337
) {
334-
final updatedReplies = replies?.sortedUpsert(
338+
final currentReplies = replies ?? [];
339+
final updatedReplies = currentReplies.sortedUpsert(
335340
reply,
336341
key: (it) => it.id,
337342
compare: comparator,

packages/stream_feeds/lib/src/state/activity.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import '../models/poll_data.dart';
1313
import '../models/poll_option_data.dart';
1414
import '../models/poll_vote_data.dart';
1515
import '../models/request/activity_add_comment_request.dart';
16+
import '../models/request/activity_update_comment_request.dart';
1617
import '../models/threaded_comment_data.dart';
1718
import '../repository/activities_repository.dart';
1819
import '../repository/comments_repository.dart';
@@ -196,9 +197,10 @@ class Activity with Disposable {
196197
/// Returns a [Result] containing the updated [CommentData] or an error.
197198
Future<Result<CommentData>> updateComment(
198199
String commentId,
199-
api.UpdateCommentRequest request,
200+
ActivityUpdateCommentRequest request,
200201
) async {
201-
final result = await commentsRepository.updateComment(commentId, request);
202+
final result =
203+
await commentsRepository.updateComment(commentId, request.toRequest());
202204

203205
result.onSuccess(_commentsList.notifier.onCommentUpdated);
204206

packages/stream_feeds/lib/src/state/activity_state.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:state_notifier/state_notifier.dart';
33
import 'package:stream_core/stream_core.dart';
44

55
import '../models/activity_data.dart';
6+
import '../models/pagination_data.dart';
67
import '../models/poll_data.dart';
78
import '../models/poll_vote_data.dart';
89
import '../models/threaded_comment_data.dart';
@@ -31,7 +32,10 @@ class ActivityStateNotifier extends StateNotifier<ActivityState> {
3132
void _setupCommentListSynchronization() {
3233
_removeCommentListListener = commentList.addListener((commentListState) {
3334
// Synchronize state with the comment list state
34-
state = state.copyWith(comments: commentListState.comments);
35+
state = state.copyWith(
36+
comments: commentListState.comments,
37+
commentsPagination: commentListState.pagination,
38+
);
3539
});
3640
}
3741

@@ -174,6 +178,7 @@ class ActivityState with _$ActivityState {
174178
const ActivityState({
175179
this.activity,
176180
this.comments = const [],
181+
this.commentsPagination,
177182
this.poll,
178183
});
179184

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

198+
/// Pagination information for [comments].
199+
@override
200+
final PaginationData? commentsPagination;
201+
202+
/// Indicates whether there are more [comments] available to load.
203+
///
204+
/// Returns true if there is a next page available for pagination.
205+
bool get canLoadMoreComments => commentsPagination?.next != null;
206+
193207
/// The poll associated with this activity, if any.
194208
///
195209
/// Contains poll information including options, votes, and poll state.

packages/stream_feeds/lib/src/state/activity_state.freezed.dart

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/stream_feeds/lib/src/state/bookmark_folder_list.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class BookmarkFolderList extends Disposable {
5252
/// Queries the initial list of bookmark folders based on the provided [BookmarkFoldersQuery].
5353
///
5454
/// Returns a [Result] containing a list of [BookmarkFolderData] or an error.
55-
Future<Result<List<BookmarkFolderData>>> get() => _queryBookmarkFolders(query);
55+
Future<Result<List<BookmarkFolderData>>> get() =>
56+
_queryBookmarkFolders(query);
5657

5758
/// Loads more bookmark folders based on the current pagination state.
5859
///

packages/stream_feeds/lib/src/state/feed.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class Feed with Disposable {
6666
_eventsSubscription = eventsEmitter.listen(handler.handleEvent);
6767
}
6868

69+
FeedId get fid => query.fid;
6970
final FeedQuery query;
7071
final String currentUserId;
7172

packages/stream_feeds/lib/stream_feeds.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ export 'src/models/feed_id.dart';
77
export 'src/models/feed_input_data.dart';
88
export 'src/models/feed_member_request_data.dart';
99
export 'src/models/poll_data.dart';
10+
export 'src/models/request/activity_add_comment_request.dart'
11+
show ActivityAddCommentRequest;
12+
export 'src/models/request/activity_update_comment_request.dart'
13+
show ActivityUpdateCommentRequest;
14+
export 'src/models/threaded_comment_data.dart';
1015
export 'src/models/user_data.dart';
16+
export 'src/state/activity.dart';
1117
export 'src/state/feed.dart';
18+
export 'src/state/feed_state.dart';
1219
export 'src/state/query/feed_query.dart';

0 commit comments

Comments
 (0)