Skip to content

Commit 1bf5178

Browse files
gnpricechrisbobbe
authored andcommitted
api [nfc]: Use TopicName in notification types
1 parent 2f75f56 commit 1bf5178

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lib/api/notifications.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
import 'package:json_annotation/json_annotation.dart';
33

4+
import 'model/model.dart';
5+
46
part 'notifications.g.dart';
57

68
/// Parsed version of an FCM message, of any type.
@@ -187,7 +189,7 @@ class FcmMessageChannelRecipient extends FcmMessageRecipient {
187189
@JsonKey(name: 'stream')
188190
final String? streamName;
189191

190-
final String topic;
192+
final TopicName topic;
191193

192194
FcmMessageChannelRecipient({required this.streamId, required this.streamName, required this.topic});
193195

lib/api/notifications.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/api/notifications_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:checks/checks.dart';
22
import 'package:test/scaffolding.dart';
3+
import 'package:zulip/api/model/model.dart';
34
import 'package:zulip/api/notifications.dart';
45

56
import '../stdlib_checks.dart';
@@ -81,7 +82,7 @@ void main() {
8182
..recipient.isA<FcmMessageChannelRecipient>().which((it) => it
8283
..streamId.equals(42)
8384
..streamName.equals(streamJson['stream']!)
84-
..topic.equals(streamJson['topic']!))
85+
..topic.jsonEquals(streamJson['topic']!))
8586
..content.equals(streamJson['content']!)
8687
..time.equals(1546300800);
8788

@@ -279,7 +280,7 @@ extension MessageFcmMessageChecks on Subject<MessageFcmMessage> {
279280
extension FcmMessageChannelRecipientChecks on Subject<FcmMessageChannelRecipient> {
280281
Subject<int> get streamId => has((x) => x.streamId, 'streamId');
281282
Subject<String?> get streamName => has((x) => x.streamName, 'streamName');
282-
Subject<String> get topic => has((x) => x.topic, 'topic');
283+
Subject<TopicName> get topic => has((x) => x.topic, 'topic');
283284
}
284285

285286
extension FcmMessageDmRecipientChecks on Subject<FcmMessageDmRecipient> {

0 commit comments

Comments
 (0)