Skip to content

Commit cdb28a8

Browse files
committed
fix issue #165: Unread Messages count
1 parent cb75845 commit cdb28a8

File tree

4 files changed

+53
-43
lines changed

4 files changed

+53
-43
lines changed

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

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,18 @@ class Group<T> extends Equatable {
6060
@JsonSerializable(createToJson: true, genericArgumentFactories: true)
6161
class NotificationGroup<T> extends Group<T> {
6262
/// [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(
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+
this.unread,
73+
this.unseen})
74+
: super(
7375
id: id,
7476
group: group,
7577
activities: activities,
@@ -91,12 +93,11 @@ class NotificationGroup<T> extends Group<T> {
9193
/// True if the notification group is seen.
9294
final bool? isSeen;
9395

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

101102
/// Serialize to json
102103
@override

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

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

packages/stream_feed/test/fixtures/notification_group.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@
2828
"created_at": "2001-09-11T00:01:02.000",
2929
"updated_at": "2001-09-11T00:01:02.000",
3030
"is_read": true,
31-
"is_seen": true
32-
}
31+
"is_seen": true,
32+
"unread": 0,
33+
"unseen": 1
34+
}

packages/stream_feed/test/models_test.dart

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -428,31 +428,32 @@ void main() {
428428

429429
group('NotificationGroup', () {
430430
final notificationGroup = NotificationGroup(
431-
id: 'test',
432-
group: 'test',
433-
activities: [
434-
Activity(
435-
target: 'test',
436-
foreignId: 'test',
437-
id: 'test',
438-
analytics: const {'test': 'test'},
439-
extraContext: const {'test': 'test'},
440-
origin: 'test',
441-
score: 1,
442-
extraData: const {'test': 'test'},
443-
actor: 'test',
444-
verb: 'test',
445-
object: 'test',
446-
to: <FeedId>[FeedId('slug', 'id')],
447-
time: DateTime.parse('2001-09-11T00:01:02.000'),
448-
),
449-
],
450-
actorCount: 1,
451-
createdAt: DateTime.parse('2001-09-11T00:01:02.000'),
452-
updatedAt: DateTime.parse('2001-09-11T00:01:02.000'),
453-
isRead: true,
454-
isSeen: true,
455-
);
431+
id: 'test',
432+
group: 'test',
433+
activities: [
434+
Activity(
435+
target: 'test',
436+
foreignId: 'test',
437+
id: 'test',
438+
analytics: const {'test': 'test'},
439+
extraContext: const {'test': 'test'},
440+
origin: 'test',
441+
score: 1,
442+
extraData: const {'test': 'test'},
443+
actor: 'test',
444+
verb: 'test',
445+
object: 'test',
446+
to: <FeedId>[FeedId('slug', 'id')],
447+
time: DateTime.parse('2001-09-11T00:01:02.000'),
448+
),
449+
],
450+
actorCount: 1,
451+
createdAt: DateTime.parse('2001-09-11T00:01:02.000'),
452+
updatedAt: DateTime.parse('2001-09-11T00:01:02.000'),
453+
isRead: true,
454+
isSeen: true,
455+
unread: 0,
456+
unseen: 1);
456457

457458
test('fromJson', () {
458459
final notificationGroupJson =
@@ -489,7 +490,9 @@ void main() {
489490
'created_at': '2001-09-11T00:01:02.000',
490491
'updated_at': '2001-09-11T00:01:02.000',
491492
'is_read': true,
492-
'is_seen': true
493+
'is_seen': true,
494+
'unread': 0,
495+
'unseen': 1,
493496
});
494497
});
495498
});

0 commit comments

Comments
 (0)