Browse Source

neon: cleanup notifications logic

Co-authored-by: Kate <26026535+provokateurin@users.noreply.github.com>
pull/373/head
Nikolas Rimikis 1 year ago
parent
commit
56c22b727d
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 35
      packages/neon/neon/lib/src/app.dart

35
packages/neon/neon/lib/src/app.dart

@ -113,34 +113,39 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
if (account == null) { if (account == null) {
return; return;
} }
final app = Provider.of<Iterable<AppImplementation>>(context, listen: false).find('notifications');
if (app != null) {
await _accountsBloc.getAppsBlocFor(account).getAppBloc<NotificationsBlocInterface>(app).refresh();
}
};
Global.onPushNotificationClicked = (final pushNotificationWithAccountID) async {
final allAppImplementations = Provider.of<Iterable<AppImplementation>>(context, listen: false); final allAppImplementations = Provider.of<Iterable<AppImplementation>>(context, listen: false);
final app = allAppImplementations.find('notifications') as NotificationsAppInterface?;
final app = (pushNotificationWithAccountID.subject.app != null if (app == null) {
? allAppImplementations.find(pushNotificationWithAccountID.subject.app!) return;
: null) ?? }
allAppImplementations.find('notifications');
await _accountsBloc.getAppsBlocFor(account).getAppBloc<NotificationsBlocInterface>(app).refresh();
};
Global.onPushNotificationClicked = (final pushNotificationWithAccountID) async {
final account = _accountsBloc.accounts.value.find(pushNotificationWithAccountID.accountID); final account = _accountsBloc.accounts.value.find(pushNotificationWithAccountID.accountID);
if (account == null) { if (account == null) {
return; return;
} }
_accountsBloc.setActiveAccount(account); _accountsBloc.setActiveAccount(account);
if (app != null) {
if (app.id != 'notifications') { final allAppImplementations = Provider.of<Iterable<AppImplementation>>(context, listen: false);
final notificationsApp = allAppImplementations.find('notifications') as NotificationsAppInterface?;
if (notificationsApp != null) {
_accountsBloc _accountsBloc
.getAppsBlocFor(account) .getAppsBlocFor(account)
.getAppBloc<NotificationsBlocInterface>(app) .getAppBloc<NotificationsBlocInterface>(notificationsApp)
.deleteNotification(pushNotificationWithAccountID.subject.nid!); .deleteNotification(pushNotificationWithAccountID.subject.nid!);
} }
await _openAppFromExternal(account, app.id);
final app = allAppImplementations.find(pushNotificationWithAccountID.subject.app!) ?? notificationsApp;
if (app == null) {
return;
} }
await _openAppFromExternal(account, app.id);
}; };
final details = await localNotificationsPlugin.getNotificationAppLaunchDetails(); final details = await localNotificationsPlugin.getNotificationAppLaunchDetails();

Loading…
Cancel
Save