Skip to content

Commit

Permalink
chore: Fetch cached presence
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Nov 27, 2023
1 parent 61ade15 commit ee599c1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/widgets/presence_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ class PresenceBuilder extends StatelessWidget {
if (userId == null) return builder(context, null);

final client = this.client ?? Matrix.of(context).client;
return StreamBuilder(
stream: client.onPresenceChanged.stream
.where((cachedPresence) => cachedPresence.userid == userId),
builder: (context, snapshot) => builder(
context,
snapshot.data ?? client.presences[userId],
return FutureBuilder<CachedPresence>(
future: client.fetchCurrentPresence(userId),
builder: (context, cachedPresenceSnapshot) => StreamBuilder(
stream: client.onPresenceChanged.stream
.where((cachedPresence) => cachedPresence.userid == userId),
builder: (context, snapshot) => builder(
context,
snapshot.data ?? cachedPresenceSnapshot.data,
),
),
);
}
Expand Down

0 comments on commit ee599c1

Please sign in to comment.