mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-16 19:18:52 +01:00
Don't show notification for active conversation, improve messaging performance
Previously, the app would mark the conversation read every time a message was received. Now, when we're receiving a message, we can see which conversation is open (if any), and mark it read during the inital write. Now we don't need to query and do another transaction for marking read
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.moez.QKSMS.manager
|
||||
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class ActiveConversationManagerImpl @Inject constructor() : ActiveConversationManager {
|
||||
|
||||
private var threadId: Long? = null
|
||||
|
||||
override fun setActiveConversation(threadId: Long?) {
|
||||
this.threadId = threadId
|
||||
}
|
||||
|
||||
override fun getActiveConversation(): Long? {
|
||||
return threadId
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,6 +36,7 @@ import com.klinker.android.send_message.StripAccents
|
||||
import com.klinker.android.send_message.Transaction
|
||||
import com.moez.QKSMS.compat.TelephonyCompat
|
||||
import com.moez.QKSMS.extensions.anyOf
|
||||
import com.moez.QKSMS.manager.ActiveConversationManager
|
||||
import com.moez.QKSMS.manager.KeyManager
|
||||
import com.moez.QKSMS.model.Attachment
|
||||
import com.moez.QKSMS.model.Conversation
|
||||
@@ -57,6 +58,7 @@ import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class MessageRepositoryImpl @Inject constructor(
|
||||
private val activeConversationManager: ActiveConversationManager,
|
||||
private val context: Context,
|
||||
private val messageIds: KeyManager,
|
||||
private val imageRepository: ImageRepository,
|
||||
@@ -351,6 +353,7 @@ class MessageRepositoryImpl @Inject constructor(
|
||||
threadId = TelephonyCompat.getOrCreateThreadId(context, address)
|
||||
boxId = Telephony.Sms.MESSAGE_TYPE_INBOX
|
||||
type = "sms"
|
||||
read = activeConversationManager.getActiveConversation() == threadId
|
||||
}
|
||||
val realm = Realm.getDefaultInstance()
|
||||
var managedMessage: Message? = null
|
||||
|
||||
Reference in New Issue
Block a user