mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-19 04:55:09 +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,
|
invite: invite,
|
||||||
);
|
);
|
||||||
if (getRoomById(roomId) == null) {
|
if (getRoomById(roomId) == null) {
|
||||||
// Wait for room actually appears in sync
|
// Wait for room actually appears in sync and is encrypted. This is a
|
||||||
await onSync.stream
|
// workaround for https://github.com/krille-chan/fluffychat/issues/520
|
||||||
.firstWhere((sync) => sync.rooms?.join?.containsKey(roomId) ?? false);
|
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 {
|
Future<Room?> getStoriesRoom(BuildContext context) async {
|
||||||
|
|
Loading…
Reference in a new issue