fetchCurrentPresence method

Future<CachedPresence> fetchCurrentPresence()

The newest presence of this user if there is any. Fetches it from the server if necessary or returns offline.

Implementation

Future<CachedPresence> fetchCurrentPresence() async {
  final cachedPresence = room.client.presences[id];
  if (cachedPresence != null) {
    return cachedPresence;
  }
  try {
    final newPresence = await room.client.getPresence(id);
    return CachedPresence.fromPresenceResponse(newPresence, id);
  } catch (e) {
    return CachedPresence.neverSeen(id);
  }
}