Fix TelegramHelper#removeOldMessages

This commit is contained in:
Alex Sytnyk 2018-07-09 19:04:03 +03:00
parent 90cc7dd8f4
commit e5e3918029

View file

@ -366,7 +366,7 @@ class TelegramHelper private constructor() {
if (oldContent is TdApi.MessageText) { if (oldContent is TdApi.MessageText) {
message.content = parseOsmAndBotLocation(oldContent.text.text) message.content = parseOsmAndBotLocation(oldContent.text.text)
} }
removeOldMessages(message.senderUserId) removeOldMessages(message.senderUserId, message.chatId)
usersLocationMessages[message.id] = message usersLocationMessages[message.id] = message
val chatTitle = chats[message.chatId]?.title val chatTitle = chats[message.chatId]?.title
if (chatTitle != null) { if (chatTitle != null) {
@ -377,13 +377,13 @@ class TelegramHelper private constructor() {
} }
} }
private fun removeOldMessages(userId: Int) { private fun removeOldMessages(userId: Int, chatId: Long) {
users[userId]?.also { user -> val user = users[userId]
if (user.username != OSMAND_BOT_USERNAME) { if (user != null && user.username != OSMAND_BOT_USERNAME) {
usersLocationMessages.values.filter { it.senderUserId == userId }.forEach { usersLocationMessages.values.filter { it.senderUserId == userId && it.chatId == chatId }
.forEach {
usersLocationMessages.remove(it.id) usersLocationMessages.remove(it.id)
} }
}
} }
} }