From 9e971674e8a372bb3aab3c0e6eccf80f41278eeb Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sun, 15 Mar 2020 09:31:49 +0100 Subject: [PATCH] [Presence] Calculate time --- lib/src/presence.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/src/presence.dart b/lib/src/presence.dart index 7ff871a..062b1c6 100644 --- a/lib/src/presence.dart +++ b/lib/src/presence.dart @@ -39,6 +39,7 @@ class Presence { final int lastActiveAgo; final PresenceType presence; final String statusMsg; + final DateTime time; Presence.fromJson(Map json) : sender = json['sender'], @@ -46,6 +47,9 @@ class Presence { avatarUrl = MxContent(json['content']['avatar_url'] ?? ""), currentlyActive = json['content']['currently_active'], lastActiveAgo = json['content']['last_active_ago'], + time = DateTime.fromMillisecondsSinceEpoch( + DateTime.now().millisecondsSinceEpoch - + (json['content']['last_active_ago'] ?? 0)), presence = PresenceType.values.firstWhere( (e) => e.toString() == "PresenceType.${json['content']['presence']}",