mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Decrease db thrashing when starting expiration timers for messages.
This commit is contained in:
@@ -49,10 +49,6 @@ public abstract class DatabaseTable {
|
||||
|
||||
protected void notifyConversationListeners(Set<Long> threadIds) {
|
||||
ApplicationDependencies.getDatabaseObserver().notifyConversationListeners(threadIds);
|
||||
|
||||
for (long threadId : threadIds) {
|
||||
notifyConversationListeners(threadId);
|
||||
}
|
||||
}
|
||||
|
||||
protected void notifyConversationListeners(long threadId) {
|
||||
|
||||
@@ -2186,27 +2186,19 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
|
||||
@JvmOverloads
|
||||
fun markExpireStarted(id: Long, startedTimestamp: Long = System.currentTimeMillis()) {
|
||||
markExpireStarted(setOf(id), startedTimestamp)
|
||||
markExpireStarted(setOf(id to startedTimestamp))
|
||||
}
|
||||
|
||||
fun markExpireStarted(ids: Collection<Long>, startedAtTimestamp: Long) {
|
||||
var threadId: Long = -1
|
||||
fun markExpireStarted(ids: Collection<kotlin.Pair<Long, Long>>) {
|
||||
writableDatabase.withinTransaction { db ->
|
||||
for (id in ids) {
|
||||
for ((id, startedAtTimestamp) in ids) {
|
||||
db.update(TABLE_NAME)
|
||||
.values(EXPIRE_STARTED to startedAtTimestamp)
|
||||
.where("$ID = ? AND ($EXPIRE_STARTED = 0 OR $EXPIRE_STARTED > ?)", id, startedAtTimestamp)
|
||||
.run()
|
||||
|
||||
if (threadId < 0) {
|
||||
threadId = getThreadIdForMessage(id)
|
||||
}
|
||||
ApplicationDependencies.getDatabaseObserver().notifyMessageUpdateObservers(MessageId(id))
|
||||
}
|
||||
|
||||
threads.update(threadId, false)
|
||||
}
|
||||
|
||||
notifyConversationListeners(threadId)
|
||||
}
|
||||
|
||||
fun markAsNotified(id: Long) {
|
||||
|
||||
Reference in New Issue
Block a user