From f884e8082f30568f0e498e10990812fa29140236 Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Mon, 25 Oct 2021 10:46:58 +0200 Subject: [PATCH] chore: Update SDK --- lib/pages/chat.dart | 8 ++++---- lib/pages/views/chat_view.dart | 3 +-- lib/utils/background_push.dart | 5 ++--- lib/utils/matrix_sdk_extensions.dart/event_extension.dart | 2 +- .../flutter_matrix_hive_database.dart | 6 +++--- lib/widgets/event_content/message.dart | 4 ++-- pubspec.lock | 2 +- pubspec.yaml | 2 +- 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/pages/chat.dart b/lib/pages/chat.dart index f4756d5c..f2337ed2 100644 --- a/lib/pages/chat.dart +++ b/lib/pages/chat.dart @@ -468,7 +468,7 @@ class ChatController extends State { await showFutureLoadingDialog( context: context, future: () async { - if (event.status > 0) { + if (event.status.isSent) { if (event.canRedact) { await event.redactEvent(); } else { @@ -505,7 +505,7 @@ class ChatController extends State { } bool get canEditSelectedEvents { - if (selectedEvents.length != 1 || selectedEvents.first.status < 1) { + if (selectedEvents.length != 1 || !selectedEvents.first.status.isSent) { return false; } return currentRoomBundle @@ -527,12 +527,12 @@ class ChatController extends State { void sendAgainAction() { final event = selectedEvents.first; - if (event.status == -1) { + if (event.status.isError) { event.sendAgain(); } final allEditEvents = event .aggregatedEvents(timeline, RelationshipTypes.edit) - .where((e) => e.status == -1); + .where((e) => e.status.isError); for (final e in allEditEvents) { e.sendAgain(); } diff --git a/lib/pages/views/chat_view.dart b/lib/pages/views/chat_view.dart index 2993b6a3..634e95f1 100644 --- a/lib/pages/views/chat_view.dart +++ b/lib/pages/views/chat_view.dart @@ -535,8 +535,7 @@ class ChatView extends StatelessWidget { ? controller.selectedEvents.first .getDisplayEvent( controller.timeline) - .status > - 0 + .status.isSent ? SizedBox( height: 56, child: TextButton( diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart index 131b6875..53ad3254 100644 --- a/lib/utils/background_push.dart +++ b/lib/utils/background_push.dart @@ -461,8 +461,7 @@ class BackgroundPush { Future eventExists(String roomId, String eventId) async { final room = client.getRoomById(roomId); if (room == null) return false; - return (await client.database.getEventById(client.id, eventId, room)) != - null; + return (await client.database.getEventById(eventId, room)) != null; } /// Workaround for the problem that local notification IDs must be int but we @@ -579,7 +578,7 @@ class BackgroundPush { throw 'Room not found'; } await room.postLoad(); - final event = await client.database.getEventById(client.id, eventId, room); + final event = await client.database.getEventById(eventId, room); final activeRoomId = router.currentState.pathParameters['roomid']; diff --git a/lib/utils/matrix_sdk_extensions.dart/event_extension.dart b/lib/utils/matrix_sdk_extensions.dart/event_extension.dart index 1db731f4..daee1f56 100644 --- a/lib/utils/matrix_sdk_extensions.dart/event_extension.dart +++ b/lib/utils/matrix_sdk_extensions.dart/event_extension.dart @@ -16,7 +16,7 @@ extension LocalizedBody on Event { } IconData get statusIcon { - switch (status) { + switch (status.intValue) { case -1: return Icons.error_outline; case 0: diff --git a/lib/utils/matrix_sdk_extensions.dart/flutter_matrix_hive_database.dart b/lib/utils/matrix_sdk_extensions.dart/flutter_matrix_hive_database.dart index 537d6caa..db6593ca 100644 --- a/lib/utils/matrix_sdk_extensions.dart/flutter_matrix_hive_database.dart +++ b/lib/utils/matrix_sdk_extensions.dart/flutter_matrix_hive_database.dart @@ -36,8 +36,8 @@ class FlutterMatrixHiveStore extends FamedlySdkHiveDatabase { } @override - Future clear(int clientId) async { - await super.clear(clientId); + Future clear() async { + await super.clear(); await _customBox.deleteAll(_customBox.keys); await _customBox.close(); } @@ -84,7 +84,7 @@ class FlutterMatrixHiveStore extends FamedlySdkHiveDatabase { await db.open(); } catch (e, s) { Logs().e('Unable to open Hive. Delete and try again...', e, s); - await db.clear(client.id); + await db.clear(); await db.open(); } return db; diff --git a/lib/widgets/event_content/message.dart b/lib/widgets/event_content/message.dart index dda8c321..e410de30 100644 --- a/lib/widgets/event_content/message.dart +++ b/lib/widgets/event_content/message.dart @@ -75,7 +75,7 @@ class Message extends StatelessWidget { color = Colors.transparent; textColor = Theme.of(context).textTheme.bodyText2.color; } else if (ownMessage) { - color = displayEvent.status == -1 + color = displayEvent.status.isError ? Colors.redAccent : Theme.of(context).primaryColor; } @@ -125,7 +125,7 @@ class Message extends StatelessWidget { type: 'm.room.message', room: event.room, roomId: event.roomId, - status: 1, + status: EventStatus.sent, originServerTs: DateTime.now(), ); return InkWell( diff --git a/pubspec.lock b/pubspec.lock index 25f631c6..bd8228ed 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -748,7 +748,7 @@ packages: name: matrix url: "https://pub.dartlang.org" source: hosted - version: "0.5.5" + version: "0.6.1" matrix_api_lite: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4964925c..d6e96e9c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -45,7 +45,7 @@ dependencies: intl: any localstorage: ^4.0.0+1 lottie: ^1.2.1 - matrix: ^0.5.5 + matrix: ^0.6.1 matrix_link_text: ^1.0.2 native_imaging: git: https://gitlab.com/famedly/libraries/native_imaging.git