Sort by most recent chatIDs (#9946)

When we `lazy_load` iMessage chats, return chats w/ most recent msg
first (matches what is visualized in app).
pull/10155/head
Lance Martin 1 year ago committed by GitHub
parent cf5a50469f
commit 387813bfb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -108,8 +108,13 @@ class IMessageChatLoader(chat_loaders.BaseChatLoader):
) from e
cursor = conn.cursor()
# Fetch the list of chat IDs
cursor.execute("SELECT ROWID FROM chat")
# Fetch the list of chat IDs sorted by time (most recent first)
query = """SELECT chat_id
FROM message
JOIN chat_message_join ON message.ROWID = chat_message_join.message_id
GROUP BY chat_id
ORDER BY MAX(date) DESC;"""
cursor.execute(query)
chat_ids = [row[0] for row in cursor.fetchall()]
for chat_id in chat_ids:

Loading…
Cancel
Save