chore: Lookup l10n in pushhelper if null

This commit is contained in:
Krille 2023-02-25 15:26:17 +01:00
commit 8f77f133a3
3 changed files with 8 additions and 6 deletions

View file

@ -43,10 +43,12 @@ Future<void> pushHelper(
onDidReceiveNotificationResponse: onSelectNotification,
onDidReceiveBackgroundNotificationResponse: onSelectNotification,
);
l10n ??= lookupL10n(const Locale('en'));
flutterLocalNotificationsPlugin.show(
0,
l10n?.newMessageInFluffyChat ?? 'New message in FluffyChat', // default to hardcoded value if l10n is null
l10n?.openAppToReadMessages ?? 'Open app to read messages', // default to hardcoded value if l10n is null
l10n.newMessageInFluffyChat,
l10n.openAppToReadMessages,
NotificationDetails(
iOS: const DarwinNotificationDetails(),
android: AndroidNotificationDetails(
@ -54,7 +56,7 @@ Future<void> pushHelper(
AppConfig.pushNotificationsChannelName,
channelDescription: AppConfig.pushNotificationsChannelDescription,
number: notification.counts?.unread,
ticker: l10n?.unreadChats(notification.counts?.unread ?? 1) ?? '1 unread chat', // default to hardcoded value if l10n is null
ticker: l10n.unreadChats(notification.counts?.unread ?? 1),
importance: Importance.max,
priority: Priority.high,
),