forked from Nexus/nexus
clean up and improve notifications
Thanks to Gomuks' new handling, we have sender displayname and avatar, and can use android's conversation notifications. On other platforms, we just append sender name to the body, bolded if possible. This also improves the logic on when to send notifications, as we drop notifs where `response["notification"]` is null. We also now correctly set if notifications should play a sound or not, based on `PushNotification.sound`. `PushNotification.image` handling might come sometime in the future, but it seems hard on Android.
This commit is contained in:
parent
a6fe80fea2
commit
d1724932b2
5 changed files with 139 additions and 39 deletions
|
|
@ -31,6 +31,7 @@ import "package:nexus/models/requests/get_room_state.dart";
|
|||
import "package:nexus/models/requests/get_space_hierarchy.dart";
|
||||
import "package:nexus/models/requests/join_room.dart";
|
||||
import "package:nexus/models/profile_response.dart";
|
||||
import "package:nexus/models/push_notification.dart";
|
||||
import "package:nexus/models/recovery_key.dart";
|
||||
import "package:nexus/models/requests/oauth/exchange_token.dart";
|
||||
import "package:nexus/models/requests/oauth/get_auth_url.dart";
|
||||
|
|
@ -47,7 +48,6 @@ import "package:nexus/models/requests/set_membership.dart";
|
|||
import "package:nexus/models/requests/set_state.dart";
|
||||
import "package:nexus/models/requests/upload_media.dart";
|
||||
import "package:nexus/models/room.dart";
|
||||
import "package:nexus/models/room_metadata.dart";
|
||||
import "package:nexus/models/room_summary.dart";
|
||||
import "package:nexus/models/space_hierarchy.dart";
|
||||
import "package:nexus/models/spec_versions_response.dart";
|
||||
|
|
@ -128,18 +128,15 @@ class ClientController extends AsyncNotifier<int> {
|
|||
}
|
||||
}
|
||||
|
||||
Future<(Event, RoomMetadata)?> handlePush(Map<String, dynamic> data) async {
|
||||
Future<PushNotification?> handlePush(Map<String, dynamic> data) async {
|
||||
final response = await callGomuksMethod(
|
||||
data,
|
||||
(handle, data) async => GomuksHandlePush(handle, data),
|
||||
);
|
||||
|
||||
return response == null
|
||||
return response?["notification"] == null
|
||||
? null
|
||||
: (
|
||||
Event.fromJson(response["event"]),
|
||||
RoomMetadata.fromJson(response["room"]),
|
||||
);
|
||||
: .fromJson(response["notification"]);
|
||||
}
|
||||
|
||||
Future<dynamic> _sendCommand(
|
||||
|
|
|
|||
Loading…
Reference in a new issue