Trying to plumb list changes...
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user