Private
Public Access
1
0

Trying to plumb list changes...

This commit is contained in:
2023-08-17 01:07:15 -07:00
parent b38c51d108
commit 770bb496f5
4 changed files with 28 additions and 6 deletions

View File

@@ -122,9 +122,11 @@ class ChatRepository(
val conversations = fetchConversations()
database.writeConversations(conversations)
// TODO: Delete non-existent conversations.
// Sync top N number of conversations' message content
Log.d(REPO_LOG, "Synchronizing messages")
val sortedConversations = conversations.sortedBy { it.date }
val sortedConversations = conversations.sortedBy { it.date }.reversed()
for (conversation in sortedConversations.take(CONVERSATION_MESSAGE_SYNC_COUNT)) {
val messages = fetchMessages(conversation)
database.writeMessages(messages, conversation)