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.
This commit is contained in:
Christian Pauly 2021-06-01 12:55:45 +02:00
parent 26261ecd5e
commit d0f67f914a
2 changed files with 3 additions and 1 deletions

View File

@ -173,7 +173,7 @@ class Event extends MatrixEvent {
: DateTime.now(),
unsigned: unsigned,
room: room,
sortOrder: sortOrder ?? 0.0,
sortOrder: sortOrder ?? unsigned.tryGet<num>(sortOrderKey) ?? 0.0,
);
}

View File

@ -54,6 +54,8 @@ const Map<HistoryVisibility, String> _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'.