mirror of
https://github.com/oxen-io/session-android.git
synced 2023-12-14 02:53:01 +01:00
* fix: background polling issue for 1on1 messages, update the HomeDiffUtil.kt to include more cases to compare content equality, add synchronized ConversationNotificationDebouncer.kt and reduce the debouncer time * fix: replace updateNotification to be thread-specific to fix unread behaviour and currently visible thread behaviour * refactor: remove trimmed text limits
36 lines
1.2 KiB
Kotlin
36 lines
1.2 KiB
Kotlin
package org.thoughtcrime.securesms.database
|
|
|
|
import android.annotation.SuppressLint
|
|
import android.content.Context
|
|
import org.session.libsession.utilities.Debouncer
|
|
import org.thoughtcrime.securesms.ApplicationContext
|
|
|
|
class ConversationNotificationDebouncer(private val context: Context) {
|
|
private val threadIDs = mutableSetOf<Long>()
|
|
private val handler = (context.applicationContext as ApplicationContext).conversationListNotificationHandler
|
|
private val debouncer = Debouncer(handler, 100)
|
|
|
|
companion object {
|
|
@SuppressLint("StaticFieldLeak")
|
|
lateinit var shared: ConversationNotificationDebouncer
|
|
|
|
@Synchronized
|
|
fun get(context: Context): ConversationNotificationDebouncer {
|
|
if (::shared.isInitialized) { return shared }
|
|
shared = ConversationNotificationDebouncer(context)
|
|
return shared
|
|
}
|
|
}
|
|
|
|
fun notify(threadID: Long) {
|
|
threadIDs.add(threadID)
|
|
debouncer.publish { publish() }
|
|
}
|
|
|
|
private fun publish() {
|
|
for (threadID in threadIDs.toList()) {
|
|
context.contentResolver.notifyChange(DatabaseContentProviders.Conversation.getUriForThread(threadID), null)
|
|
}
|
|
threadIDs.clear()
|
|
}
|
|
} |