From 2a41af9c9269e0a701f3814ffefe918fb45db6ba Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sat, 1 Jun 2024 20:38:06 +1200 Subject: [PATCH] fix for updated at going crazy in ui --- web.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/web.py b/web.py index 8cb48de..d466cde 100644 --- a/web.py +++ b/web.py @@ -812,16 +812,16 @@ async def index(request): SELECT CASE WHEN source_hash < destination_hash THEN source_hash ELSE destination_hash END AS normalized_source, CASE WHEN source_hash < destination_hash THEN destination_hash ELSE source_hash END AS normalized_destination, - MAX(updated_at) AS most_recent_updated_at + MAX(created_at) AS most_recent_created_at FROM lxmf_messages GROUP BY normalized_source, normalized_destination ) SELECT normalized_source AS source_hash, normalized_destination AS destination_hash, - most_recent_updated_at + most_recent_created_at FROM NormalizedMessages - ORDER BY most_recent_updated_at DESC; + ORDER BY most_recent_created_at DESC; """ # execute sql query @@ -834,7 +834,7 @@ async def index(request): # get data from row source_hash = row[0] destination_hash = row[1] - updated_at = row[2] + created_at = row[2] # determine destination hash of other user if source_hash == self.local_lxmf_destination.hexhash: @@ -847,7 +847,9 @@ async def index(request): "name": self.get_lxmf_conversation_name(other_user_hash), "destination_hash": other_user_hash, "is_unread": self.is_lxmf_conversation_unread(other_user_hash), - "updated_at": updated_at, + # we say the conversation was updated when the latest message was created + # otherwise this will go crazy when sending a message, as the updated_at on the latest message changes very frequently + "updated_at": created_at, }) return web.json_response({