mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 09:35:12 +00:00
fix: First story appears to be unencrypted sometimes
This commit is contained in:
parent
b5aa68476f
commit
cafb1e3d79
1 changed files with 15 additions and 4 deletions
|
@ -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,
|
||||
);
|
||||
}
|
||||
return getRoomById(roomId)!;
|
||||
final room = getRoomById(roomId);
|
||||
if (room == null || !room.encrypted) {
|
||||
throw Exception(
|
||||
'Unable to create and wait for encrypted room to appear in Sync.',
|
||||
);
|
||||
}
|
||||
return room;
|
||||
}
|
||||
|
||||
Future<Room?> getStoriesRoom(BuildContext context) async {
|
||||
|
|
Loading…
Reference in a new issue