refactor: make room nullsafe
This commit is contained in:
parent
fb0a84d7b2
commit
ebd5bc3d24
|
|
@ -312,6 +312,7 @@ class Encryption {
|
||||||
roomID: roomId,
|
roomID: roomId,
|
||||||
type: updateType,
|
type: updateType,
|
||||||
),
|
),
|
||||||
|
client,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return event;
|
return event;
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,8 @@ class KeyManager {
|
||||||
_requestedSessionIds.clear();
|
_requestedSessionIds.clear();
|
||||||
for (final room in client.rooms) {
|
for (final room in client.rooms) {
|
||||||
final lastEvent = room.lastEvent;
|
final lastEvent = room.lastEvent;
|
||||||
if (lastEvent.type == EventTypes.Encrypted &&
|
if (lastEvent != null &&
|
||||||
|
lastEvent.type == EventTypes.Encrypted &&
|
||||||
lastEvent.content['can_request_session'] == true) {
|
lastEvent.content['can_request_session'] == true) {
|
||||||
try {
|
try {
|
||||||
maybeAutoRequest(room.id, lastEvent.content['session_id'],
|
maybeAutoRequest(room.id, lastEvent.content['session_id'],
|
||||||
|
|
|
||||||
|
|
@ -316,8 +316,8 @@ class Client extends MatrixApi {
|
||||||
}
|
}
|
||||||
for (final room in rooms) {
|
for (final room in rooms) {
|
||||||
if (room.membership == Membership.invite &&
|
if (room.membership == Membership.invite &&
|
||||||
room.getState(EventTypes.RoomMember, userID)?.senderId == userId &&
|
room.getState(EventTypes.RoomMember, userID!)?.senderId == userId &&
|
||||||
room.getState(EventTypes.RoomMember, userID).content['is_direct'] ==
|
room.getState(EventTypes.RoomMember, userID!)?.content['is_direct'] ==
|
||||||
true) {
|
true) {
|
||||||
return room.id;
|
return room.id;
|
||||||
}
|
}
|
||||||
|
|
@ -613,7 +613,7 @@ class Client extends MatrixApi {
|
||||||
if (rooms.isNotEmpty) {
|
if (rooms.isNotEmpty) {
|
||||||
final profileSet = <Profile>{};
|
final profileSet = <Profile>{};
|
||||||
for (final room in rooms) {
|
for (final room in rooms) {
|
||||||
final user = room.getUserByMXIDSync(userID);
|
final user = room.getUserByMXIDSync(userID!);
|
||||||
profileSet.add(Profile.fromJson(user.content));
|
profileSet.add(Profile.fromJson(user.content));
|
||||||
}
|
}
|
||||||
if (profileSet.length == 1) return profileSet.first;
|
if (profileSet.length == 1) return profileSet.first;
|
||||||
|
|
@ -1297,7 +1297,7 @@ class Client extends MatrixApi {
|
||||||
final id = entry.key;
|
final id = entry.key;
|
||||||
final room = entry.value;
|
final room = entry.value;
|
||||||
|
|
||||||
await database?.storeRoomUpdate(id, room);
|
await database?.storeRoomUpdate(id, room, this);
|
||||||
_updateRoomsByRoomUpdate(id, room);
|
_updateRoomsByRoomUpdate(id, room);
|
||||||
|
|
||||||
/// Handle now all room events and save them in the database
|
/// Handle now all room events and save them in the database
|
||||||
|
|
@ -1377,7 +1377,7 @@ class Client extends MatrixApi {
|
||||||
// there.
|
// there.
|
||||||
if (event['type'] == 'm.receipt') {
|
if (event['type'] == 'm.receipt') {
|
||||||
var room = getRoomById(id);
|
var room = getRoomById(id);
|
||||||
room ??= Room(id: id);
|
room ??= Room(id: id, client: this);
|
||||||
|
|
||||||
final receiptStateContent =
|
final receiptStateContent =
|
||||||
room.roomAccountData['m.receipt']?.content ?? {};
|
room.roomAccountData['m.receipt']?.content ?? {};
|
||||||
|
|
@ -1455,7 +1455,7 @@ class Client extends MatrixApi {
|
||||||
}
|
}
|
||||||
_updateRoomsByEventUpdate(update);
|
_updateRoomsByEventUpdate(update);
|
||||||
if (type != EventUpdateType.ephemeral) {
|
if (type != EventUpdateType.ephemeral) {
|
||||||
await database?.storeEventUpdate(update);
|
await database?.storeEventUpdate(update, this);
|
||||||
}
|
}
|
||||||
if (encryptionEnabled) {
|
if (encryptionEnabled) {
|
||||||
await encryption?.handleEventUpdate(update);
|
await encryption?.handleEventUpdate(update);
|
||||||
|
|
@ -1521,9 +1521,10 @@ class Client extends MatrixApi {
|
||||||
id: roomId,
|
id: roomId,
|
||||||
membership: membership,
|
membership: membership,
|
||||||
prev_batch: chatUpdate.timeline?.prevBatch,
|
prev_batch: chatUpdate.timeline?.prevBatch,
|
||||||
highlightCount: chatUpdate.unreadNotifications?.highlightCount,
|
highlightCount:
|
||||||
|
chatUpdate.unreadNotifications?.highlightCount ?? 0,
|
||||||
notificationCount:
|
notificationCount:
|
||||||
chatUpdate.unreadNotifications?.notificationCount,
|
chatUpdate.unreadNotifications?.notificationCount ?? 0,
|
||||||
summary: chatUpdate.summary,
|
summary: chatUpdate.summary,
|
||||||
client: this,
|
client: this,
|
||||||
)
|
)
|
||||||
|
|
@ -1593,10 +1594,10 @@ class Client extends MatrixApi {
|
||||||
} else {
|
} else {
|
||||||
if (stateEvent.type != EventTypes.Message ||
|
if (stateEvent.type != EventTypes.Message ||
|
||||||
stateEvent.relationshipType != RelationshipTypes.edit ||
|
stateEvent.relationshipType != RelationshipTypes.edit ||
|
||||||
stateEvent.relationshipEventId == room.lastEvent.eventId ||
|
stateEvent.relationshipEventId == room.lastEvent?.eventId ||
|
||||||
((room.lastEvent.relationshipType == RelationshipTypes.edit &&
|
((room.lastEvent?.relationshipType == RelationshipTypes.edit &&
|
||||||
stateEvent.relationshipEventId ==
|
stateEvent.relationshipEventId ==
|
||||||
room.lastEvent.relationshipEventId))) {
|
room.lastEvent?.relationshipEventId))) {
|
||||||
room.setState(stateEvent);
|
room.setState(stateEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,11 +58,12 @@ abstract class DatabaseApi {
|
||||||
|
|
||||||
/// Stores a RoomUpdate object in the database. Must be called inside of
|
/// Stores a RoomUpdate object in the database. Must be called inside of
|
||||||
/// [transaction].
|
/// [transaction].
|
||||||
Future<void> storeRoomUpdate(String roomId, SyncRoomUpdate roomUpdate);
|
Future<void> storeRoomUpdate(
|
||||||
|
String roomId, SyncRoomUpdate roomUpdate, Client client);
|
||||||
|
|
||||||
/// Stores an EventUpdate object in the database. Must be called inside of
|
/// Stores an EventUpdate object in the database. Must be called inside of
|
||||||
/// [transaction].
|
/// [transaction].
|
||||||
Future<void> storeEventUpdate(EventUpdate eventUpdate);
|
Future<void> storeEventUpdate(EventUpdate eventUpdate, Client client);
|
||||||
|
|
||||||
Future<Event?> getEventById(String eventId, Room room);
|
Future<Event?> getEventById(String eventId, Room room);
|
||||||
|
|
||||||
|
|
@ -232,6 +233,7 @@ abstract class DatabaseApi {
|
||||||
Future setRoomPrevBatch(
|
Future setRoomPrevBatch(
|
||||||
String prevBatch,
|
String prevBatch,
|
||||||
String roomId,
|
String roomId,
|
||||||
|
Client client,
|
||||||
);
|
);
|
||||||
|
|
||||||
Future resetNotificationCount(String roomId);
|
Future resetNotificationCount(String roomId);
|
||||||
|
|
|
||||||
|
|
@ -518,10 +518,12 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
||||||
// We always need the member event for ourself
|
// We always need the member event for ourself
|
||||||
final membersToPostload = <String>{if (userID != null) userID};
|
final membersToPostload = <String>{if (userID != null) userID};
|
||||||
// If the room is a direct chat, those IDs should be there too
|
// If the room is a direct chat, those IDs should be there too
|
||||||
if (room.isDirectChat) membersToPostload.add(room.directChatMatrixID);
|
if (room.isDirectChat)
|
||||||
|
membersToPostload.add(room.directChatMatrixID!);
|
||||||
// the lastEvent message preview might have an author we need to fetch, if it is a group chat
|
// the lastEvent message preview might have an author we need to fetch, if it is a group chat
|
||||||
if (room.getState(EventTypes.Message) != null && !room.isDirectChat) {
|
final lastEvent = room.getState(EventTypes.Message);
|
||||||
membersToPostload.add(room.getState(EventTypes.Message).senderId);
|
if (lastEvent != null && !room.isDirectChat) {
|
||||||
|
membersToPostload.add(lastEvent.senderId);
|
||||||
}
|
}
|
||||||
// if the room has no name and no canonical alias, its name is calculated
|
// if the room has no name and no canonical alias, its name is calculated
|
||||||
// based on the heroes of the room
|
// based on the heroes of the room
|
||||||
|
|
@ -529,7 +531,7 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
||||||
room.getState(EventTypes.RoomCanonicalAlias) == null) {
|
room.getState(EventTypes.RoomCanonicalAlias) == null) {
|
||||||
// we don't have a name and no canonical alias, so we'll need to
|
// we don't have a name and no canonical alias, so we'll need to
|
||||||
// post-load the heroes
|
// post-load the heroes
|
||||||
membersToPostload.addAll(room.summary?.mHeroes ?? []);
|
membersToPostload.addAll(room.summary.mHeroes ?? []);
|
||||||
}
|
}
|
||||||
// Load members
|
// Load members
|
||||||
for (final userId in membersToPostload) {
|
for (final userId in membersToPostload) {
|
||||||
|
|
@ -817,10 +819,11 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> setRoomPrevBatch(String prevBatch, String roomId) async {
|
Future<void> setRoomPrevBatch(
|
||||||
|
String prevBatch, String roomId, Client client) async {
|
||||||
final raw = await _roomsBox.get(roomId.toHiveKey);
|
final raw = await _roomsBox.get(roomId.toHiveKey);
|
||||||
if (raw == null) return;
|
if (raw == null) return;
|
||||||
final room = Room.fromJson(convertToJson(raw));
|
final room = Room.fromJson(convertToJson(raw), client);
|
||||||
room.prev_batch = prevBatch;
|
room.prev_batch = prevBatch;
|
||||||
await _roomsBox.put(roomId.toHiveKey, room.toJson());
|
await _roomsBox.put(roomId.toHiveKey, room.toJson());
|
||||||
return;
|
return;
|
||||||
|
|
@ -861,13 +864,13 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> storeEventUpdate(EventUpdate eventUpdate) async {
|
Future<void> storeEventUpdate(EventUpdate eventUpdate, Client client) async {
|
||||||
// Ephemerals should not be stored
|
// Ephemerals should not be stored
|
||||||
if (eventUpdate.type == EventUpdateType.ephemeral) return;
|
if (eventUpdate.type == EventUpdateType.ephemeral) return;
|
||||||
|
|
||||||
// In case of this is a redaction event
|
// In case of this is a redaction event
|
||||||
if (eventUpdate.content['type'] == EventTypes.Redaction) {
|
if (eventUpdate.content['type'] == EventTypes.Redaction) {
|
||||||
final tmpRoom = Room(id: eventUpdate.roomID);
|
final tmpRoom = Room(id: eventUpdate.roomID, client: client);
|
||||||
final event = await getEventById(eventUpdate.content['redacts'], tmpRoom);
|
final event = await getEventById(eventUpdate.content['redacts'], tmpRoom);
|
||||||
if (event != null) {
|
if (event != null) {
|
||||||
event.setRedactionEvent(Event.fromJson(eventUpdate.content, tmpRoom));
|
event.setRedactionEvent(Event.fromJson(eventUpdate.content, tmpRoom));
|
||||||
|
|
@ -1077,7 +1080,8 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> storeRoomUpdate(String roomId, SyncRoomUpdate roomUpdate) async {
|
Future<void> storeRoomUpdate(
|
||||||
|
String roomId, SyncRoomUpdate roomUpdate, Client client) async {
|
||||||
// Leave room if membership is leave
|
// Leave room if membership is leave
|
||||||
if (roomUpdate is LeftRoomUpdate) {
|
if (roomUpdate is LeftRoomUpdate) {
|
||||||
await forgetRoom(roomId);
|
await forgetRoom(roomId);
|
||||||
|
|
@ -1094,26 +1098,31 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
||||||
roomId.toHiveKey,
|
roomId.toHiveKey,
|
||||||
roomUpdate is JoinedRoomUpdate
|
roomUpdate is JoinedRoomUpdate
|
||||||
? Room(
|
? Room(
|
||||||
|
client: client,
|
||||||
id: roomId,
|
id: roomId,
|
||||||
membership: membership,
|
membership: membership,
|
||||||
highlightCount:
|
highlightCount:
|
||||||
roomUpdate.unreadNotifications?.highlightCount?.toInt(),
|
roomUpdate.unreadNotifications?.highlightCount?.toInt() ??
|
||||||
|
0,
|
||||||
notificationCount: roomUpdate
|
notificationCount: roomUpdate
|
||||||
.unreadNotifications?.notificationCount
|
.unreadNotifications?.notificationCount
|
||||||
?.toInt(),
|
?.toInt() ??
|
||||||
|
0,
|
||||||
prev_batch: roomUpdate.timeline?.prevBatch,
|
prev_batch: roomUpdate.timeline?.prevBatch,
|
||||||
summary: roomUpdate.summary,
|
summary: roomUpdate.summary,
|
||||||
).toJson()
|
).toJson()
|
||||||
: Room(
|
: Room(
|
||||||
|
client: client,
|
||||||
id: roomId,
|
id: roomId,
|
||||||
membership: membership,
|
membership: membership,
|
||||||
).toJson());
|
).toJson());
|
||||||
} else if (roomUpdate is JoinedRoomUpdate) {
|
} else if (roomUpdate is JoinedRoomUpdate) {
|
||||||
final currentRawRoom = await _roomsBox.get(roomId.toHiveKey);
|
final currentRawRoom = await _roomsBox.get(roomId.toHiveKey);
|
||||||
final currentRoom = Room.fromJson(convertToJson(currentRawRoom));
|
final currentRoom = Room.fromJson(convertToJson(currentRawRoom), client);
|
||||||
await _roomsBox.put(
|
await _roomsBox.put(
|
||||||
roomId.toHiveKey,
|
roomId.toHiveKey,
|
||||||
Room(
|
Room(
|
||||||
|
client: client,
|
||||||
id: roomId,
|
id: roomId,
|
||||||
membership: membership,
|
membership: membership,
|
||||||
highlightCount:
|
highlightCount:
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ class Event extends MatrixEvent {
|
||||||
|
|
||||||
bool get redacted => redactedBecause != null;
|
bool get redacted => redactedBecause != null;
|
||||||
|
|
||||||
User? get stateKeyUser => room?.getUserByMXIDSync(stateKey);
|
User? get stateKeyUser => room?.getUserByMXIDSync(stateKey!);
|
||||||
|
|
||||||
Event({
|
Event({
|
||||||
this.status = defaultStatus,
|
this.status = defaultStatus,
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -171,9 +171,10 @@ extension CommandsClientExtension on Client {
|
||||||
});
|
});
|
||||||
addCommand('myroomnick', (CommandArgs args) async {
|
addCommand('myroomnick', (CommandArgs args) async {
|
||||||
final currentEventJson = args.room
|
final currentEventJson = args.room
|
||||||
.getState(EventTypes.RoomMember, args.room.client.userID)
|
.getState(EventTypes.RoomMember, args.room.client.userID!)
|
||||||
.content
|
?.content
|
||||||
.copy();
|
.copy() ??
|
||||||
|
{};
|
||||||
currentEventJson['displayname'] = args.msg;
|
currentEventJson['displayname'] = args.msg;
|
||||||
return await args.room.client.setRoomStateWithKey(
|
return await args.room.client.setRoomStateWithKey(
|
||||||
args.room.id,
|
args.room.id,
|
||||||
|
|
@ -184,9 +185,10 @@ extension CommandsClientExtension on Client {
|
||||||
});
|
});
|
||||||
addCommand('myroomavatar', (CommandArgs args) async {
|
addCommand('myroomavatar', (CommandArgs args) async {
|
||||||
final currentEventJson = args.room
|
final currentEventJson = args.room
|
||||||
.getState(EventTypes.RoomMember, args.room.client.userID)
|
.getState(EventTypes.RoomMember, args.room.client.userID!)
|
||||||
.content
|
?.content
|
||||||
.copy();
|
.copy() ??
|
||||||
|
{};
|
||||||
currentEventJson['avatar_url'] = args.msg;
|
currentEventJson['avatar_url'] = args.msg;
|
||||||
return await args.room.client.setRoomStateWithKey(
|
return await args.room.client.setRoomStateWithKey(
|
||||||
args.room.id,
|
args.room.id,
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ class PillSyntax extends InlineSyntax {
|
||||||
}
|
}
|
||||||
|
|
||||||
class MentionSyntax extends InlineSyntax {
|
class MentionSyntax extends InlineSyntax {
|
||||||
final String Function(String)? getMention;
|
final String? Function(String)? getMention;
|
||||||
MentionSyntax(this.getMention) : super(r'(@(?:\[[^\]:]+\]|\w+)(?:#\w+)?)');
|
MentionSyntax(this.getMention) : super(r'(@(?:\[[^\]:]+\]|\w+)(?:#\w+)?)');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -206,7 +206,7 @@ class MentionSyntax extends InlineSyntax {
|
||||||
String markdown(
|
String markdown(
|
||||||
String text, {
|
String text, {
|
||||||
Map<String, Map<String, String>> Function()? getEmotePacks,
|
Map<String, Map<String, String>> Function()? getEmotePacks,
|
||||||
String Function(String)? getMention,
|
String? Function(String)? getMention,
|
||||||
}) {
|
}) {
|
||||||
var ret = markdownToHtml(
|
var ret = markdownToHtml(
|
||||||
text,
|
text,
|
||||||
|
|
|
||||||
|
|
@ -115,8 +115,9 @@ void testDatabase(
|
||||||
'limited_timeline': false,
|
'limited_timeline': false,
|
||||||
'membership': Membership.join,
|
'membership': Membership.join,
|
||||||
});
|
});
|
||||||
await database.storeRoomUpdate('!testroom', roomUpdate);
|
final client = Client('testclient');
|
||||||
final rooms = await database.getRoomList(Client('testclient'));
|
await database.storeRoomUpdate('!testroom', roomUpdate, client);
|
||||||
|
final rooms = await database.getRoomList(client);
|
||||||
expect(rooms.single.id, '!testroom');
|
expect(rooms.single.id, '!testroom');
|
||||||
});
|
});
|
||||||
test('getRoomList', () async {
|
test('getRoomList', () async {
|
||||||
|
|
@ -124,8 +125,9 @@ void testDatabase(
|
||||||
expect(list.single.id, '!testroom');
|
expect(list.single.id, '!testroom');
|
||||||
});
|
});
|
||||||
test('setRoomPrevBatch', () async {
|
test('setRoomPrevBatch', () async {
|
||||||
await database.setRoomPrevBatch('1234', '!testroom');
|
final client = Client('testclient');
|
||||||
final rooms = await database.getRoomList(Client('testclient'));
|
await database.setRoomPrevBatch('1234', '!testroom', client);
|
||||||
|
final rooms = await database.getRoomList(client);
|
||||||
expect(rooms.single.prev_batch, '1234');
|
expect(rooms.single.prev_batch, '1234');
|
||||||
});
|
});
|
||||||
test('forgetRoom', () async {
|
test('forgetRoom', () async {
|
||||||
|
|
@ -192,28 +194,28 @@ void testDatabase(
|
||||||
});
|
});
|
||||||
test('storeEventUpdate', () async {
|
test('storeEventUpdate', () async {
|
||||||
await database.storeEventUpdate(
|
await database.storeEventUpdate(
|
||||||
EventUpdate(
|
EventUpdate(
|
||||||
roomID: '!testroom:example.com',
|
roomID: '!testroom:example.com',
|
||||||
type: EventUpdateType.timeline,
|
type: EventUpdateType.timeline,
|
||||||
content: {
|
content: {
|
||||||
'type': EventTypes.Message,
|
'type': EventTypes.Message,
|
||||||
'content': {
|
'content': {
|
||||||
'body': '* edit 3',
|
'body': '* edit 3',
|
||||||
'msgtype': 'm.text',
|
|
||||||
'm.new_content': {
|
|
||||||
'body': 'edit 3',
|
|
||||||
'msgtype': 'm.text',
|
'msgtype': 'm.text',
|
||||||
|
'm.new_content': {
|
||||||
|
'body': 'edit 3',
|
||||||
|
'msgtype': 'm.text',
|
||||||
|
},
|
||||||
|
'm.relates_to': {
|
||||||
|
'event_id': '\$source',
|
||||||
|
'rel_type': RelationshipTypes.edit,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'm.relates_to': {
|
'event_id': '\$event:example.com',
|
||||||
'event_id': '\$source',
|
'sender': '@bob:example.org',
|
||||||
'rel_type': RelationshipTypes.edit,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
'event_id': '\$event:example.com',
|
),
|
||||||
'sender': '@bob:example.org',
|
Client('testclient'));
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
test('getEventById', () async {
|
test('getEventById', () async {
|
||||||
final event = await database.getEventById(
|
final event = await database.getEventById(
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('storeEventUpdate', () async {
|
test('storeEventUpdate', () async {
|
||||||
final database = await getDatabase(null);
|
final client = Client('testclient');
|
||||||
|
final database = await getDatabase(client);
|
||||||
// store a simple update
|
// store a simple update
|
||||||
var update = EventUpdate(
|
var update = EventUpdate(
|
||||||
type: EventUpdateType.timeline,
|
type: EventUpdateType.timeline,
|
||||||
|
|
@ -56,7 +57,7 @@ void main() {
|
||||||
'sender': '@blah:blubb',
|
'sender': '@blah:blubb',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
await database.storeEventUpdate(update);
|
await database.storeEventUpdate(update, client);
|
||||||
var event = await database.getEventById('\$event-1', room);
|
var event = await database.getEventById('\$event-1', room);
|
||||||
expect(event.eventId, '\$event-1');
|
expect(event.eventId, '\$event-1');
|
||||||
|
|
||||||
|
|
@ -73,7 +74,7 @@ void main() {
|
||||||
'status': EventStatus.sending.intValue,
|
'status': EventStatus.sending.intValue,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
await database.storeEventUpdate(update);
|
await database.storeEventUpdate(update, client);
|
||||||
event = await database.getEventById('transaction-1', room);
|
event = await database.getEventById('transaction-1', room);
|
||||||
expect(event.eventId, 'transaction-1');
|
expect(event.eventId, 'transaction-1');
|
||||||
update = EventUpdate(
|
update = EventUpdate(
|
||||||
|
|
@ -91,7 +92,7 @@ void main() {
|
||||||
'status': EventStatus.sent.intValue,
|
'status': EventStatus.sent.intValue,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
await database.storeEventUpdate(update);
|
await database.storeEventUpdate(update, client);
|
||||||
event = await database.getEventById('transaction-1', room);
|
event = await database.getEventById('transaction-1', room);
|
||||||
expect(event, null);
|
expect(event, null);
|
||||||
event = await database.getEventById('\$event-2', room);
|
event = await database.getEventById('\$event-2', room);
|
||||||
|
|
@ -109,7 +110,7 @@ void main() {
|
||||||
'status': EventStatus.sending.intValue,
|
'status': EventStatus.sending.intValue,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
await database.storeEventUpdate(update);
|
await database.storeEventUpdate(update, client);
|
||||||
event = await database.getEventById('\$event-3', room);
|
event = await database.getEventById('\$event-3', room);
|
||||||
expect(event.eventId, '\$event-3');
|
expect(event.eventId, '\$event-3');
|
||||||
update = EventUpdate(
|
update = EventUpdate(
|
||||||
|
|
@ -127,7 +128,7 @@ void main() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
await database.storeEventUpdate(update);
|
await database.storeEventUpdate(update, client);
|
||||||
event = await database.getEventById('\$event-3', room);
|
event = await database.getEventById('\$event-3', room);
|
||||||
expect(event.eventId, '\$event-3');
|
expect(event.eventId, '\$event-3');
|
||||||
expect(event.status, EventStatus.sent);
|
expect(event.status, EventStatus.sent);
|
||||||
|
|
@ -147,7 +148,7 @@ void main() {
|
||||||
'status': EventStatus.synced.intValue,
|
'status': EventStatus.synced.intValue,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
await database.storeEventUpdate(update);
|
await database.storeEventUpdate(update, client);
|
||||||
event = await database.getEventById('\$event-4', room);
|
event = await database.getEventById('\$event-4', room);
|
||||||
expect(event.eventId, '\$event-4');
|
expect(event.eventId, '\$event-4');
|
||||||
update = EventUpdate(
|
update = EventUpdate(
|
||||||
|
|
@ -165,7 +166,7 @@ void main() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
await database.storeEventUpdate(update);
|
await database.storeEventUpdate(update, client);
|
||||||
event = await database.getEventById('\$event-4', room);
|
event = await database.getEventById('\$event-4', room);
|
||||||
expect(event.eventId, '\$event-4');
|
expect(event.eventId, '\$event-4');
|
||||||
expect(event.status, EventStatus.synced);
|
expect(event.status, EventStatus.synced);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue