From d0f67f914a5bbe349c408ba449e749b35272502d Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Tue, 1 Jun 2021 12:55:45 +0200 Subject: [PATCH] refactor: Add sortOrderKey and check for this while Event creation This makes it easier to write a store which just stores the Event json and does not have a dedicated scheme for each object like Moor has. --- lib/src/event.dart | 2 +- lib/src/room.dart | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/event.dart b/lib/src/event.dart index 4f72d350..e2530250 100644 --- a/lib/src/event.dart +++ b/lib/src/event.dart @@ -173,7 +173,7 @@ class Event extends MatrixEvent { : DateTime.now(), unsigned: unsigned, room: room, - sortOrder: sortOrder ?? 0.0, + sortOrder: sortOrder ?? unsigned.tryGet(sortOrderKey) ?? 0.0, ); } diff --git a/lib/src/room.dart b/lib/src/room.dart index 91bb8941..fe387836 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -54,6 +54,8 @@ const Map _historyVisibilityMap = { const String messageSendingStatusKey = 'com.famedly.famedlysdk.message_sending_status'; +const String sortOrderKey = 'com.famedly.famedlysdk.sort_order'; + /// Represents a Matrix room. class Room { /// The full qualified Matrix ID for the room in the format '!localid:server.abc'.