diff --git a/lib/controllers/notifications.dart b/lib/controllers/notifications.dart index faf5e8c..2109cb7 100644 --- a/lib/controllers/notifications.dart +++ b/lib/controllers/notifications.dart @@ -1,6 +1,8 @@ import "dart:io"; import "package:flutter_local_notifications/flutter_local_notifications.dart"; +// ignore: implementation_imports +import "package:flutter_local_notifications_linux/src/model/hint.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; class NotificationsController @@ -75,7 +77,16 @@ class NotificationsController ), iOS: .new(), macOS: .new(), - linux: .new(icon: icon == null ? null : FilePathLinuxIcon(icon.path)), + linux: .new( + customHints: icon == null + ? null + : [ + .new( + name: "image-path", + value: LinuxHintStringValue(icon.path), + ), + ], + ), windows: .new(), ); diff --git a/lib/controllers/unified_push.dart b/lib/controllers/unified_push.dart index c4d32ac..0698bda 100644 --- a/lib/controllers/unified_push.dart +++ b/lib/controllers/unified_push.dart @@ -53,11 +53,19 @@ class UnifiedPushController extends AsyncNotifier { RoomsController.provider.select((rooms) => rooms[event.roomId]), ); + final avatar = room?.metadata?.avatar; + final icon = avatar == null + ? null + : await ref + .read(ClientController.provider.notifier) + .downloadMedia(.new(mxc: avatar, isAvatar: true)); + await ref .read(NotificationsController.provider.notifier) .send( id: event.eventId.hashCode & 0x7fffffff, title: room?.metadata?.name ?? "New Message", + icon: icon, body: switch (event.content) { MessageContent(:final body) => body, // TODO: Handle more types diff --git a/pubspec.lock b/pubspec.lock index 9f951f3..5f85f85 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -520,7 +520,7 @@ packages: source: hosted version: "22.3.0" flutter_local_notifications_linux: - dependency: transitive + dependency: "direct main" description: name: flutter_local_notifications_linux sha256: "9ca97e63776f29ab1b955725c09999fc2c150523269db150c39274f2a43c5a8b" diff --git a/pubspec.yaml b/pubspec.yaml index 79a3378..de72e0e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -81,7 +81,8 @@ dependencies: material_ui: 1.1.0 unifiedpush: 6.2.0 unifiedpush_storage_shared_preferences: 1.0.0 - flutter_local_notifications: ^22.3.0 + flutter_local_notifications: 22.3.0 + flutter_local_notifications_linux: 8.0.1 dev_dependencies: build_runner: 2.16.0