Fix TelegramHelper#removeOldMessages
This commit is contained in:
parent
90cc7dd8f4
commit
e5e3918029
1 changed files with 6 additions and 6 deletions
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue