Fix small issues

This commit is contained in:
Alex Sytnyk 2018-07-13 14:42:57 +03:00
parent 2cde7dcb3f
commit 951065e21c
2 changed files with 7 additions and 11 deletions

View file

@ -53,11 +53,10 @@ class ShowLocationHelper(private val app: TelegramApplication) {
execOsmandApi {
val messages = telegramHelper.getMessages()
for (message in messages) {
val chatId = message.chatId
val date = Math.max(message.date, message.editDate) * 1000L
val expired = System.currentTimeMillis() - date > app.settings.userLocationExpireTime
if (expired) {
removeMapPoint(chatId, message)
removeMapPoint(message.chatId, message)
}
}
}

View file

@ -104,10 +104,10 @@ class TelegramHelper private constructor() {
fun getUser(id: Int) = users[id]
fun getUserMessage(user: TdApi.User) =
usersLocationMessages.values.firstOrNull { it.senderUserId == user.id }
usersLocationMessages.values.firstOrNull { it.senderUserId == user.id }
fun getChatMessages(chatId: Long) =
usersLocationMessages.values.filter { it.chatId == chatId }
usersLocationMessages.values.filter { it.chatId == chatId }
fun getMessages() = usersLocationMessages.values.toList()
@ -363,9 +363,8 @@ class TelegramHelper private constructor() {
}
removeOldMessages(message.senderUserId, message.chatId)
usersLocationMessages[message.id] = message
val chatId = message.chatId
incomingMessagesListeners.forEach {
it.onReceiveChatLocationMessages(chatId, message)
incomingMessagesListeners.forEach {
it.onReceiveChatLocationMessages(message.chatId, message)
}
}
}
@ -840,9 +839,8 @@ class TelegramHelper private constructor() {
synchronized(message) {
message.editDate = updateMessageEdited.editDate
}
val chatId = message.chatId
incomingMessagesListeners.forEach {
it.onReceiveChatLocationMessages(chatId, message)
it.onReceiveChatLocationMessages(message.chatId, message)
}
}
}
@ -862,9 +860,8 @@ class TelegramHelper private constructor() {
newContent
}
}
val chatId = message.chatId
incomingMessagesListeners.forEach {
it.onReceiveChatLocationMessages(chatId, message)
it.onReceiveChatLocationMessages(message.chatId, message)
}
}
}