Skip to content

Commit 3f6b93d

Browse files
authored
Merge pull request #167 from GetStream/support-extraData-null-value
2 parents de915c0 + f747f9b commit 3f6b93d

File tree

91 files changed

+3045
-25
lines changed

Some content is hidden

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

91 files changed

+3045
-25
lines changed

packages/stream_feed/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.4.0+1: 07/12/2021
2+
3+
- fix: support null values `extraData`'s map
4+
- fix: utc date parsing with a `JsonConverter<DateTime,String>` and `intl`
5+
- fix: unread/unseen count in `NotificationFeedMeta` model
6+
17
## 0.4.0: 29/10/2021
28

39
- breaking: `StreamFeedClient.connect` is now `StreamFeedClient` for better user session handling.

packages/stream_feed/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ await client.flatFeed('user', 'ken').updateActivityToTargets('foreign_id:1234',
227227

228228
### Realtime (Faye)
229229

230-
Stream uses [Faye](http://faye.jcoglan.com) for realtime notifications. Below is quick guide to subscribing to feed changes
230+
Stream uses [Faye](https://faye.jcoglan.com) for realtime notifications. Below is quick guide to subscribing to feed changes
231231

232232
```dart
233233

packages/stream_feed/lib/src/client/notification_feed.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:stream_feed/src/core/models/enrichment_flags.dart';
99
import 'package:stream_feed/src/core/models/feed_id.dart';
1010
import 'package:stream_feed/src/core/models/filter.dart';
1111
import 'package:stream_feed/src/core/models/group.dart';
12+
import 'package:stream_feed/src/core/models/notification_feed_meta.dart';
1213
import 'package:stream_feed/src/core/util/default.dart';
1314
import 'package:stream_feed/src/core/util/token_helper.dart';
1415

@@ -98,6 +99,22 @@ class NotificationFeed extends AggregatedFeed {
9899
return data;
99100
}
100101

102+
/// Retrieves unread an unseen count of notification feeds
103+
Future<NotificationFeedMeta> getUnreadUnseenCounts({
104+
Filter? filter,
105+
ActivityMarker? marker,
106+
}) async {
107+
final options = {
108+
'limit': 0,
109+
...filter?.params ?? Default.filter.params,
110+
...marker?.params ?? Default.marker.params,
111+
};
112+
final token = userToken ??
113+
TokenHelper.buildFeedToken(secret!, TokenAction.read, feedId);
114+
final result = await feed.getActivities(token, feedId, options);
115+
return NotificationFeedMeta.fromJson(result.data!);
116+
}
117+
101118
/// Retrieve activities with reaction enrichment
102119
///
103120
/// {@macro filter}

packages/stream_feed/lib/src/core/models/activity.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:equatable/equatable.dart';
22
import 'package:json_annotation/json_annotation.dart';
33
import 'package:stream_feed/src/core/models/feed_id.dart';
44
import 'package:stream_feed/src/core/util/serializer.dart';
5+
import 'package:stream_feed/src/core/util/utc_converter.dart';
56

67
part 'activity.g.dart';
78

@@ -15,6 +16,7 @@ part 'activity.g.dart';
1516
///
1617
/// Read more about Activities [here](https://getstream.io/activity-feeds/docs/flutter-dart/adding_activities/?language=dart) and [here](https://activitystrea.ms/specs/json/1.0/).
1718
@JsonSerializable()
19+
@DateTimeUTCConverter()
1820
class Activity extends Equatable {
1921
/// Builds an [Activity].
2022
const Activity({

packages/stream_feed/lib/src/core/models/activity_update.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import 'package:equatable/equatable.dart';
22
import 'package:json_annotation/json_annotation.dart';
3+
import 'package:stream_feed/src/core/util/utc_converter.dart';
34

45
part 'activity_update.g.dart';
56

67
/// For updating only parts of one or more activities by changing,
78
/// adding, or removing fields.
89
@JsonSerializable()
10+
@DateTimeUTCConverter()
911
class ActivityUpdate extends Equatable {
1012
/// Builds an [ActivityUpdate].
1113
const ActivityUpdate({

packages/stream_feed/lib/src/core/models/collection_entry.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:equatable/equatable.dart';
22
import 'package:json_annotation/json_annotation.dart';
3+
import 'package:stream_feed/src/core/util/utc_converter.dart';
34
import 'package:stream_feed/stream_feed.dart';
45

56
part 'collection_entry.g.dart';
@@ -20,6 +21,7 @@ part 'collection_entry.g.dart';
2021
/// Collection endpoints can be used both client-side and server-side except
2122
/// the batch methods that are only available server-side.
2223
@JsonSerializable()
24+
@DateTimeUTCConverter()
2325
class CollectionEntry extends Equatable {
2426
/// Builds a [CollectionEntry].
2527
const CollectionEntry({

packages/stream_feed/lib/src/core/models/enriched_activity.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:stream_feed/src/core/models/collection_entry.dart';
55
import 'package:stream_feed/src/core/models/reaction.dart';
66
import 'package:stream_feed/src/core/models/user.dart';
77
import 'package:stream_feed/src/core/util/serializer.dart';
8+
import 'package:stream_feed/src/core/util/utc_converter.dart';
89

910
part 'enriched_activity.g.dart';
1011

@@ -30,9 +31,10 @@ part 'enriched_activity.g.dart';
3031
/// * T = [target]
3132
/// * Or = [origin]
3233
@JsonSerializable(genericArgumentFactories: true)
34+
@DateTimeUTCConverter()
3335
class GenericEnrichedActivity<A, Ob, T, Or> extends Equatable {
3436
//TODO: improve this
35-
// when type parameter to can a default type in Dart
37+
// when type parameter can have a default type in Dart
3638
//i.e. https://github.com/dart-lang/language/issues/283#issuecomment-839603127
3739
/// Builds an [GenericEnrichedActivity].
3840
const GenericEnrichedActivity({
@@ -62,7 +64,7 @@ class GenericEnrichedActivity<A, Ob, T, Or> extends Equatable {
6264
T Function(Object? json)? fromJsonT,
6365
Or Function(Object? json)? fromJsonOr,
6466
]) =>
65-
_$EnrichedActivityFromJson<A, Ob, T, Or>(
67+
_$GenericEnrichedActivityFromJson<A, Ob, T, Or>(
6668
Serializer.moveKeysToRoot(json, topLevelFields)!,
6769
fromJsonA ??
6870
(jsonA) => (A == User)
@@ -176,7 +178,7 @@ class GenericEnrichedActivity<A, Ob, T, Or> extends Equatable {
176178

177179
/// Map of custom user extraData
178180
@JsonKey(includeIfNull: false)
179-
final Map<String, Object>? extraData;
181+
final Map<String, Object?>? extraData;
180182

181183
GenericEnrichedActivity<A, Ob, T, Or> copyWith({
182184
A? actor,
@@ -263,6 +265,7 @@ class GenericEnrichedActivity<A, Ob, T, Or> extends Equatable {
263265
Object? Function(Or value) toJsonOr,
264266
) =>
265267
Serializer.moveKeysToMapInPlace(
266-
_$EnrichedActivityToJson(this, toJsonA, toJsonOb, toJsonT, toJsonOr),
268+
_$GenericEnrichedActivityToJson(
269+
this, toJsonA, toJsonOb, toJsonT, toJsonOr),
267270
topLevelFields);
268271
}

packages/stream_feed/lib/src/core/models/enriched_activity.g.dart

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

packages/stream_feed/lib/src/core/models/follow.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import 'package:equatable/equatable.dart';
22
import 'package:json_annotation/json_annotation.dart';
3+
import 'package:stream_feed/src/core/util/utc_converter.dart';
34

45
part 'follow.g.dart';
56

67
/// {@template follow}
78
/// Model for the follower of a feed
89
/// {@endtemplate}
910
@JsonSerializable()
11+
@DateTimeUTCConverter()
1012
class Follow extends Equatable {
1113
/// Builds a [Follow]
1214
const Follow({

packages/stream_feed/lib/src/core/models/follow.g.dart

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

0 commit comments

Comments
 (0)