From 477b13d3eb9767cc53d67f2be87b8427ba7fbf5e Mon Sep 17 00:00:00 2001 From: rhunk <101876869+rhunk@users.noreply.github.com> Date: Thu, 4 Jan 2024 23:26:55 +0100 Subject: [PATCH] fix(core/export_chat_messages): no database cache --- .../rhunk/snapenhance/core/action/impl/ExportChatMessages.kt | 2 +- .../me/rhunk/snapenhance/core/database/DatabaseAccess.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/action/impl/ExportChatMessages.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/action/impl/ExportChatMessages.kt index 75f43ffe..59cbc8a3 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/action/impl/ExportChatMessages.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/action/impl/ExportChatMessages.kt @@ -333,7 +333,7 @@ class ExportChatMessages : AbstractAction() { //first fetch the first message val conversationId = feedEntry.key!! val conversationName = feedEntry.feedDisplayName ?: feedEntry.friendDisplayName!!.split("|").lastOrNull() ?: "unknown" - val conversationParticipants = context.database.getConversationParticipants(feedEntry.key!!) + val conversationParticipants = context.database.getConversationParticipants(feedEntry.key!!, useCache = false) ?.mapNotNull { context.database.getFriendInfo(it) }?.associateBy { it.userId!! } ?: emptyMap() diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/database/DatabaseAccess.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/database/DatabaseAccess.kt index 5596f553..fc30967f 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/database/DatabaseAccess.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/database/DatabaseAccess.kt @@ -295,8 +295,8 @@ class DatabaseAccess( } } - fun getConversationParticipants(conversationId: String): List? { - if (dmOtherParticipantCache[conversationId] != null) return dmOtherParticipantCache[conversationId]?.let { listOf(myUserId, it) } + fun getConversationParticipants(conversationId: String, useCache: Boolean = true): List? { + if (dmOtherParticipantCache[conversationId] != null && useCache) return dmOtherParticipantCache[conversationId]?.let { listOf(myUserId, it) } return useDatabase(DatabaseType.ARROYO)?.performOperation { safeRawQuery( "SELECT user_id, conversation_type FROM user_conversation WHERE client_conversation_id = ?",