This commit is contained in:
Dmitriy Ruban 2019-12-23 16:09:52 +02:00
parent 4456f5151c
commit 844dbf1e4a
2 changed files with 6 additions and 4 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="buffer_time_descr">Time after which buffered location messages will be deleted</string>
<string name="buffer_time">Buffer time</string>
<string name="buffer_time">Buffer expiration time</string>
<string name="time_zone_descr">Select time zone to show in your location messages.</string>
<string name="time_zone">Time zone</string>
<string name="units_and_formats">Units &amp; formats</string>

View file

@ -152,10 +152,10 @@ class LocationMessages(val app: TelegramApplication) {
private fun removeOldBufferedMessages() {
val currentTime = System.currentTimeMillis()
if (this.bufferedMessages.isNotEmpty() && isTimeToDelete(currentTime)) {
val bufferTime = app.settings.bufferTime * 1000
val bufferExpirationTime = app.settings.bufferTime * 1000
val messages = this.bufferedMessages.toMutableList()
val expiredList = messages.filter {
currentTime - it.time > bufferTime
currentTime - it.time > bufferExpirationTime
}
expiredList.forEach { message ->
dbHelper.removeBufferedMessage(message)
@ -168,7 +168,9 @@ class LocationMessages(val app: TelegramApplication) {
private fun isTimeToDelete(currentTime: Long) = if (lastRemoveTime != null) {
currentTime - lastRemoveTime!! > 60000L
} else true
} else {
true
}
private fun readBufferedMessages() {
this.bufferedMessages = dbHelper.getBufferedMessages()