fix: First story appears to be unencrypted sometimes

pull/540/head
krille-chan 2 years ago
parent b5aa68476f
commit cafb1e3d79
No known key found for this signature in database

@ -72,11 +72,22 @@ extension ClientStoriesExtension on Client {
invite: invite,
);
if (getRoomById(roomId) == null) {
// Wait for room actually appears in sync
await onSync.stream
.firstWhere((sync) => sync.rooms?.join?.containsKey(roomId) ?? false);
// Wait for room actually appears in sync and is encrypted. This is a
// workaround for https://github.com/krille-chan/fluffychat/issues/520
await onSync.stream.firstWhere(
(sync) =>
sync.rooms?.join?[roomId]?.state
?.any((state) => state.type == EventTypes.Encrypted) ??
false,
);
}
final room = getRoomById(roomId);
if (room == null || !room.encrypted) {
throw Exception(
'Unable to create and wait for encrypted room to appear in Sync.',
);
}
return getRoomById(roomId)!;
return room;
}
Future<Room?> getStoriesRoom(BuildContext context) async {

Loading…
Cancel
Save