wait for metadata to come in on notif's rooms before sending them
This commit is contained in:
parent
a90bf00f18
commit
c2ebeffb76
1 changed files with 23 additions and 2 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import "dart:async";
|
||||
import "dart:convert";
|
||||
import "dart:io";
|
||||
|
||||
|
|
@ -78,10 +79,30 @@ class UnifiedPushController extends AsyncNotifier<bool> {
|
|||
return;
|
||||
}
|
||||
|
||||
final room = ref.read(
|
||||
RoomsController.provider.select((rooms) => rooms[event.roomId]),
|
||||
final provider = RoomsController.provider.select(
|
||||
(rooms) => rooms[event.roomId],
|
||||
);
|
||||
|
||||
if (ref.read(provider)?.metadata != null) return;
|
||||
|
||||
final completer = Completer<void>();
|
||||
|
||||
final subscription = ref.listen(provider, (previous, next) {
|
||||
if (next?.metadata != null && !completer.isCompleted) {
|
||||
completer.complete();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
await completer.future.timeout(const .new(seconds: 10));
|
||||
} on TimeoutException {
|
||||
// metadata didn't show up in time
|
||||
} finally {
|
||||
subscription.close();
|
||||
}
|
||||
|
||||
final room = ref.read(provider);
|
||||
|
||||
final avatar = room?.metadata?.avatar;
|
||||
final icon = avatar == null
|
||||
? null
|
||||
|
|
|
|||
Loading…
Reference in a new issue