Create processScannedLocationsForChat for scanned locations

This commit is contained in:
Chumva 2019-02-15 15:15:42 +02:00
parent 8cb762cde2
commit 2dbb2b657e
2 changed files with 14 additions and 16 deletions

View file

@ -92,7 +92,7 @@ class LocationMessages(val app: TelegramApplication) {
if (content != null) {
val deviceName = if (content is OsmandLocationUtils.MessageOsmAndBotLocation) content.deviceName else ""
val previousLocationMessage = lastLocationPoints.sortedBy { it.time }.firstOrNull {
it.userId == senderId && it.chatId == message.chatId && it.type == type && it.deviceName == deviceName
it.userId == senderId && it.chatId == message.chatId && it.deviceName == deviceName && it.type == type
}
if (previousLocationMessage == null || content.lastUpdated * 1000L > previousLocationMessage.time) {
log.debug("addNewLocationMessage passed ${message.id}")

View file

@ -605,16 +605,18 @@ class TelegramHelper private constructor() {
log.debug("scanChatHistory searchMessageId: ${lastMessage.id}")
} else {
log.debug("scanChatHistory finishForChat: $chatId")
if (locations.isNotEmpty()) {
locations.sortBy { message -> OsmandLocationUtils.getLastUpdatedTime(message) }
updateLastMessage(locations.last())
incomingMessagesListeners.forEach {
it.onReceiveChatLocationMessages(chatId, *locations.toTypedArray())
}
}
processScannedLocationsForChat(chatId, locations)
}
} else {
log.debug("scanChatHistory finishForChat: $chatId")
processScannedLocationsForChat(chatId, locations)
}
}
}
}
}
private fun processScannedLocationsForChat(chatId: Long, locations: MutableList<TdApi.Message>) {
if (locations.isNotEmpty()) {
locations.sortBy { message -> OsmandLocationUtils.getLastUpdatedTime(message) }
updateLastMessage(locations.last())
@ -623,10 +625,6 @@ class TelegramHelper private constructor() {
}
}
}
}
}
}
}
private fun requestUser(id: Int) {
client?.send(TdApi.GetUser(id)) { obj ->