Skip to content

Commit 1de7def

Browse files
committed
Merge remote-tracking branch 'upstream/support-extraData-null-value'
2 parents 31229b5 + 6743455 commit 1de7def

21 files changed

+148
-64
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: 01/11/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 `NotificationGroup` 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/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.

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

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

45
/// A model that wraps [foreignID] and [time]
56
class ForeignIdTimePair extends Equatable {
67
/// Builds a [ForeignIdTimePair].
78
const ForeignIdTimePair(this.foreignID, this.time);
89

10+
static const _converter = DateTimeUTCConverter();
11+
912
/// The foreign id of an activity
1013
final String foreignID;
1114

@@ -19,7 +22,7 @@ class ForeignIdTimePair extends Equatable {
1922
final pair = it as List;
2023
checkArgument(pair.length == 2, 'Invalid foreignIdTime pair');
2124
final foreignId = pair[0] as String;
22-
final time = DateTime.parse(pair[1] as String);
25+
final time = _converter.fromJson(pair[1] as String);
2326
return ForeignIdTimePair(foreignId, time);
2427
}).toList(growable: false);
2528
}

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

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
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 'group.g.dart';
56

67
/// An aggregated group type.
78
@JsonSerializable(createToJson: true, genericArgumentFactories: true)
9+
@DateTimeUTCConverter()
810
class Group<T> extends Equatable {
911
/// [Group] constructor
1012
const Group({
@@ -60,16 +62,18 @@ class Group<T> extends Equatable {
6062
@JsonSerializable(createToJson: true, genericArgumentFactories: true)
6163
class NotificationGroup<T> extends Group<T> {
6264
/// [NotificationGroup] constructor
63-
const NotificationGroup({
64-
String? id,
65-
String? group,
66-
List<T>? activities,
67-
int? actorCount,
68-
DateTime? createdAt,
69-
DateTime? updatedAt,
70-
this.isRead,
71-
this.isSeen,
72-
}) : super(
65+
const NotificationGroup(
66+
{String? id,
67+
String? group,
68+
List<T>? activities,
69+
int? actorCount,
70+
DateTime? createdAt,
71+
DateTime? updatedAt,
72+
this.isRead,
73+
this.isSeen,
74+
this.unread,
75+
this.unseen})
76+
: super(
7377
id: id,
7478
group: group,
7579
activities: activities,
@@ -91,12 +95,11 @@ class NotificationGroup<T> extends Group<T> {
9195
/// True if the notification group is seen.
9296
final bool? isSeen;
9397

98+
final int? unread;
99+
final int? unseen;
100+
94101
@override
95-
List<Object?> get props => [
96-
...super.props,
97-
isRead,
98-
isSeen,
99-
];
102+
List<Object?> get props => [...super.props, isRead, isSeen, unread, unseen];
100103

101104
/// Serialize to json
102105
@override

0 commit comments

Comments
 (0)