Skip to content

Commit 55df456

Browse files
gnpricechrisbobbe
authored andcommitted
notif [nfc]: Encapsulate registerToken a bit more
This logic is about the token, and this is the class that tracks the token in the first place, so the logic might as well live here on this class.
1 parent e6b2297 commit 55df456

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/model/store.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,9 +1522,7 @@ class UpdateMachine {
15221522
}
15231523

15241524
Future<void> _registerNotificationToken() async {
1525-
final token = NotificationService.instance.token.value;
1526-
if (token == null) return;
1527-
await NotificationService.registerToken(store.connection, token: token);
1525+
await NotificationService.instance.registerToken(store.connection);
15281526
}
15291527

15301528
/// Cleans up resources and tells the instance not to make new API requests.

lib/notifications/receive.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ class NotificationService {
147147
token.value = value;
148148
}
149149

150-
static Future<void> registerToken(ApiConnection connection, {required String token}) async {
150+
Future<void> registerToken(ApiConnection connection) async {
151+
final token = this.token.value;
152+
if (token == null) return;
153+
151154
switch (defaultTargetPlatform) {
152155
case TargetPlatform.android:
153156
await addFcmToken(connection, token: token);

0 commit comments

Comments
 (0)