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 { execOsmandApi {
val messages = telegramHelper.getMessages() val messages = telegramHelper.getMessages()
for (message in messages) { for (message in messages) {
val chatId = message.chatId
val date = Math.max(message.date, message.editDate) * 1000L val date = Math.max(message.date, message.editDate) * 1000L
val expired = System.currentTimeMillis() - date > app.settings.userLocationExpireTime val expired = System.currentTimeMillis() - date > app.settings.userLocationExpireTime
if (expired) { 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 getUser(id: Int) = users[id]
fun getUserMessage(user: TdApi.User) = fun getUserMessage(user: TdApi.User) =
usersLocationMessages.values.firstOrNull { it.senderUserId == user.id } usersLocationMessages.values.firstOrNull { it.senderUserId == user.id }
fun getChatMessages(chatId: Long) = fun getChatMessages(chatId: Long) =
usersLocationMessages.values.filter { it.chatId == chatId } usersLocationMessages.values.filter { it.chatId == chatId }
fun getMessages() = usersLocationMessages.values.toList() fun getMessages() = usersLocationMessages.values.toList()
@ -363,9 +363,8 @@ class TelegramHelper private constructor() {
} }
removeOldMessages(message.senderUserId, message.chatId) removeOldMessages(message.senderUserId, message.chatId)
usersLocationMessages[message.id] = message usersLocationMessages[message.id] = message
val chatId = message.chatId incomingMessagesListeners.forEach {
incomingMessagesListeners.forEach { it.onReceiveChatLocationMessages(message.chatId, message)
it.onReceiveChatLocationMessages(chatId, message)
} }
} }
} }
@ -840,9 +839,8 @@ class TelegramHelper private constructor() {
synchronized(message) { synchronized(message) {
message.editDate = updateMessageEdited.editDate message.editDate = updateMessageEdited.editDate
} }
val chatId = message.chatId
incomingMessagesListeners.forEach { incomingMessagesListeners.forEach {
it.onReceiveChatLocationMessages(chatId, message) it.onReceiveChatLocationMessages(message.chatId, message)
} }
} }
} }
@ -862,9 +860,8 @@ class TelegramHelper private constructor() {
newContent newContent
} }
} }
val chatId = message.chatId
incomingMessagesListeners.forEach { incomingMessagesListeners.forEach {
it.onReceiveChatLocationMessages(chatId, message) it.onReceiveChatLocationMessages(message.chatId, message)
} }
} }
} }