From e17df64f8d1d447c576a3bf517ba62c21cef0175 Mon Sep 17 00:00:00 2001
From: Nico Alt <nicoalt@posteo.org>
Date: Sun, 5 Apr 2020 12:00:00 +0000
Subject: [PATCH] Sort contact list by chat activity

---
 briar_wrapper/models/contacts.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/briar_wrapper/models/contacts.py b/briar_wrapper/models/contacts.py
index a146885..adcd584 100644
--- a/briar_wrapper/models/contacts.py
+++ b/briar_wrapper/models/contacts.py
@@ -2,6 +2,7 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 # License-Filename: LICENSE.md
 
+from operator import itemgetter
 from urllib.parse import urljoin
 
 from requests import get as _get
@@ -24,7 +25,10 @@ class Contacts(Model):
     def get(self):
         url = urljoin(BASE_HTTP_URL, self.API_ENDPOINT)
         request = _get(url, headers=self._headers)
-        return request.json()
+        contacts = request.json()
+        contacts.sort(key=itemgetter("lastChatActivity"),
+                      reverse=True)
+        return contacts
 
     def get_link(self):
         url = urljoin(BASE_HTTP_URL, self.API_ENDPOINT + "add/" + "link/")
-- 
GitLab