From 0f43e2baf22a88781dd300183c710fb62517f053 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Mon, 4 Sep 2023 19:33:58 +0200 Subject: [PATCH] chore(neon,neon_notifications,app): Adjust Signed-off-by: jld3103 --- packages/app/integration_test/screenshot_test.dart | 2 +- .../neon/neon/lib/src/blocs/push_notifications.dart | 4 ++-- packages/neon/neon/lib/src/utils/push_utils.dart | 4 +++- .../neon_notifications/lib/blocs/notifications.dart | 13 ++++++++----- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/app/integration_test/screenshot_test.dart b/packages/app/integration_test/screenshot_test.dart index 946eaff5..1e57e178 100644 --- a/packages/app/integration_test/screenshot_test.dart +++ b/packages/app/integration_test/screenshot_test.dart @@ -279,7 +279,7 @@ Future main() async { }); testWidgets('notifications', (final tester) async { - await (await getAccount('admin')).client.notifications.sendAdminNotification( + await (await getAccount('admin')).client.notifications.api.generateNotification( userId: account.username, shortMessage: 'Notifications demo', longMessage: 'This is a notifications demo of the Neon app', diff --git a/packages/neon/neon/lib/src/blocs/push_notifications.dart b/packages/neon/neon/lib/src/blocs/push_notifications.dart index a1fde3fd..a701ade7 100644 --- a/packages/neon/neon/lib/src/blocs/push_notifications.dart +++ b/packages/neon/neon/lib/src/blocs/push_notifications.dart @@ -85,7 +85,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents, debugPrint('Registering account $instance for push notifications on $endpoint'); - final subscription = await account.client.notifications.registerDevice( + final subscription = await account.client.notifications.push.registerDevice( pushTokenHash: generatePushTokenHash(endpoint), devicePublicKey: keypair.publicKey.toFormattedPEM(), proxyServer: '$endpoint#', // This is a hack to make the Nextcloud server directly push to the endpoint @@ -121,7 +121,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents, Future _unregisterUnifiedPushInstances(final List accounts) async { for (final account in accounts) { try { - await account.client.notifications.removeDevice(); + await account.client.notifications.push.removeDevice(); await UnifiedPush.unregister(account.id); await _storage.remove(_keyLastEndpoint(account)); } catch (e) { diff --git a/packages/neon/neon/lib/src/utils/push_utils.dart b/packages/neon/neon/lib/src/utils/push_utils.dart index 6e91d933..bf4f1639 100644 --- a/packages/neon/neon/lib/src/utils/push_utils.dart +++ b/packages/neon/neon/lib/src/utils/push_utils.dart @@ -103,7 +103,9 @@ class PushUtils { account = accounts.tryFind(instance); if (account != null) { notification = - (await account.client.notifications.getNotification(id: pushNotification.subject.nid!)).ocs.data; + (await account.client.notifications.endpoint.getNotification(id: pushNotification.subject.nid!)) + .ocs + .data; if (notification.icon?.endsWith('.svg') ?? false) { // Only SVG icons are supported right now (should be most of them) diff --git a/packages/neon/neon_notifications/lib/blocs/notifications.dart b/packages/neon/neon_notifications/lib/blocs/notifications.dart index 93dde480..ef9afa44 100644 --- a/packages/neon/neon_notifications/lib/blocs/notifications.dart +++ b/packages/neon/neon_notifications/lib/blocs/notifications.dart @@ -50,22 +50,25 @@ class NotificationsBloc extends InteractiveBloc @override Future refresh() async { - await RequestManager.instance.wrapNextcloud, NotificationsListNotifications>( + await RequestManager.instance.wrapNextcloud< + List, + NotificationsResponse>( _account.id, 'notifications-notifications', notifications, - () async => _account.client.notifications.listNotifications(), - (final response) => response.ocs.data.toList(), + () async => _account.client.notifications.endpoint.listNotifications(), + (final response) => response.data.ocs.data.toList(), ); } @override void deleteAllNotifications() { - wrapAction(() async => _account.client.notifications.deleteAllNotifications()); + wrapAction(() async => _account.client.notifications.endpoint.deleteAllNotifications()); } @override void deleteNotification(final int id) { - wrapAction(() async => _account.client.notifications.deleteNotification(id: id)); + wrapAction(() async => _account.client.notifications.endpoint.deleteNotification(id: id)); } }