Browse Source

chore(neon,neon_notifications,app): Adjust

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/710/head
jld3103 1 year ago
parent
commit
0f43e2baf2
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 2
      packages/app/integration_test/screenshot_test.dart
  2. 4
      packages/neon/neon/lib/src/blocs/push_notifications.dart
  3. 4
      packages/neon/neon/lib/src/utils/push_utils.dart
  4. 13
      packages/neon/neon_notifications/lib/blocs/notifications.dart

2
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',

4
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<Account> 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) {

4
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)

13
packages/neon/neon_notifications/lib/blocs/notifications.dart

@ -50,22 +50,25 @@ class NotificationsBloc extends InteractiveBloc
@override
Future refresh() async {
await RequestManager.instance.wrapNextcloud<List<NotificationsNotification>, NotificationsListNotifications>(
await RequestManager.instance.wrapNextcloud<
List<NotificationsNotification>,
NotificationsResponse<NotificationsEndpointListNotificationsResponseApplicationJson,
NotificationsEndpointEndpointListNotificationsHeaders>>(
_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));
}
}

Loading…
Cancel
Save