mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 12:08:34 +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> {
|
fun deleteAllCallLogsOnOrBeforeNow(): Single<Int> {
|
||||||
return Single.fromCallable {
|
return Single.fromCallable {
|
||||||
SignalDatabase.rawDatabase.withinTransaction {
|
SignalDatabase.rawDatabase.withinTransaction {
|
||||||
val now = System.currentTimeMillis()
|
val latestTimestamp = SignalDatabase.calls.getLatestTimestamp()
|
||||||
SignalDatabase.calls.deleteNonAdHocCallEventsOnOrBefore(now)
|
SignalDatabase.calls.deleteNonAdHocCallEventsOnOrBefore(latestTimestamp)
|
||||||
SignalDatabase.callLinks.deleteNonAdminCallLinksOnOrBefore(now)
|
SignalDatabase.callLinks.deleteNonAdminCallLinksOnOrBefore(latestTimestamp)
|
||||||
ApplicationDependencies.getJobManager().add(CallLogEventSendJob.forClearHistory(now))
|
ApplicationDependencies.getJobManager().add(CallLogEventSendJob.forClearHistory(latestTimestamp))
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalDatabase.callLinks.getAllAdminCallLinksExcept(emptySet())
|
SignalDatabase.callLinks.getAllAdminCallLinksExcept(emptySet())
|
||||||
|
|||||||
@@ -806,6 +806,17 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
|
|||||||
.run()
|
.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) {
|
fun deleteNonAdHocCallEventsOnOrBefore(timestamp: Long) {
|
||||||
val messageIdsOnOrBeforeTimestamp = """
|
val messageIdsOnOrBeforeTimestamp = """
|
||||||
SELECT $MESSAGE_ID FROM $TABLE_NAME WHERE $TIMESTAMP <= $timestamp AND $MESSAGE_ID IS NOT NULL
|
SELECT $MESSAGE_ID FROM $TABLE_NAME WHERE $TIMESTAMP <= $timestamp AND $MESSAGE_ID IS NOT NULL
|
||||||
|
|||||||
Reference in New Issue
Block a user