mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 03:58:48 +00:00
Utilize timestamp from table instead of relying on getCurrentMillis.
This commit is contained in:
committed by
Cody Henthorne
parent
fde0f3bba1
commit
f5215d715a
@@ -94,10 +94,10 @@ class CallLogRepository(
|
||||
fun deleteAllCallLogsOnOrBeforeNow(): Single<Int> {
|
||||
return Single.fromCallable {
|
||||
SignalDatabase.rawDatabase.withinTransaction {
|
||||
val now = System.currentTimeMillis()
|
||||
SignalDatabase.calls.deleteNonAdHocCallEventsOnOrBefore(now)
|
||||
SignalDatabase.callLinks.deleteNonAdminCallLinksOnOrBefore(now)
|
||||
ApplicationDependencies.getJobManager().add(CallLogEventSendJob.forClearHistory(now))
|
||||
val latestTimestamp = SignalDatabase.calls.getLatestTimestamp()
|
||||
SignalDatabase.calls.deleteNonAdHocCallEventsOnOrBefore(latestTimestamp)
|
||||
SignalDatabase.callLinks.deleteNonAdminCallLinksOnOrBefore(latestTimestamp)
|
||||
ApplicationDependencies.getJobManager().add(CallLogEventSendJob.forClearHistory(latestTimestamp))
|
||||
}
|
||||
|
||||
SignalDatabase.callLinks.getAllAdminCallLinksExcept(emptySet())
|
||||
|
||||
@@ -806,6 +806,17 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
|
||||
.run()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the most recent timestamp from the [TIMESTAMP] column
|
||||
*/
|
||||
fun getLatestTimestamp(): Long {
|
||||
val statement = """
|
||||
SELECT $TIMESTAMP FROM $TABLE_NAME ORDER BY $TIMESTAMP DESC LIMIT 1
|
||||
""".trimIndent()
|
||||
|
||||
return readableDatabase.query(statement).readToSingleLong(-1)
|
||||
}
|
||||
|
||||
fun deleteNonAdHocCallEventsOnOrBefore(timestamp: Long) {
|
||||
val messageIdsOnOrBeforeTimestamp = """
|
||||
SELECT $MESSAGE_ID FROM $TABLE_NAME WHERE $TIMESTAMP <= $timestamp AND $MESSAGE_ID IS NOT NULL
|
||||
|
||||
Reference in New Issue
Block a user