forked from signalapp/Signal-Android
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1495 from oxen-io/release-1.18.3
Merge release-1.18.3 to master
- Loading branch information
Showing
22 changed files
with
106 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/src/main/java/org/thoughtcrime/securesms/database/LastSentTimestampCache.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.thoughtcrime.securesms.database | ||
|
||
import org.session.libsession.messaging.LastSentTimestampCache | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class LastSentTimestampCache @Inject constructor( | ||
val mmsSmsDatabase: MmsSmsDatabase | ||
): LastSentTimestampCache { | ||
|
||
private val map = mutableMapOf<Long, Long>() | ||
|
||
@Synchronized | ||
override fun getTimestamp(threadId: Long): Long? = map[threadId] | ||
|
||
@Synchronized | ||
override fun submitTimestamp(threadId: Long, timestamp: Long) { | ||
if (map[threadId]?.let { timestamp <= it } == true) return | ||
|
||
map[threadId] = timestamp | ||
} | ||
|
||
@Synchronized | ||
override fun delete(threadId: Long, timestamps: List<Long>) { | ||
if (map[threadId]?.let { it !in timestamps } == true) return | ||
map.remove(threadId) | ||
refresh(threadId) | ||
} | ||
|
||
@Synchronized | ||
override fun refresh(threadId: Long) { | ||
if (map[threadId]?.let { it > 0 } == true) return | ||
val lastOutgoingTimestamp = mmsSmsDatabase.getLastOutgoingTimestamp(threadId) | ||
if (lastOutgoingTimestamp <= 0) return | ||
map[threadId] = lastOutgoingTimestamp | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.