add check for private chat
This commit is contained in:
parent
862fd08e4c
commit
3b1a79c079
2 changed files with 11 additions and 4 deletions
|
@ -106,8 +106,6 @@ class TelegramHelper private constructor() {
|
|||
|
||||
fun getCurrentUser() = currentUser
|
||||
|
||||
fun getCurrentUserId() = currentUser?.id
|
||||
|
||||
fun getUserMessage(user: TdApi.User) =
|
||||
usersLocationMessages.values.firstOrNull { it.senderUserId == user.id }
|
||||
|
||||
|
@ -138,6 +136,10 @@ class TelegramHelper private constructor() {
|
|||
return chat.type is TdApi.ChatTypeSupergroup || chat.type is TdApi.ChatTypeBasicGroup
|
||||
}
|
||||
|
||||
fun isPrivateChat(chat: TdApi.Chat): Boolean {
|
||||
return chat.type is TdApi.ChatTypePrivate
|
||||
}
|
||||
|
||||
private fun isChannel(chat: TdApi.Chat): Boolean {
|
||||
return chat.type is TdApi.ChatTypeSupergroup && (chat.type as TdApi.ChatTypeSupergroup).isChannel
|
||||
}
|
||||
|
|
|
@ -329,10 +329,15 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
private fun updateList() {
|
||||
val chatList = telegramHelper.getChatList()
|
||||
val chats: MutableList<TdApi.Chat> = mutableListOf()
|
||||
val currentUserId = telegramHelper.getCurrentUserId()
|
||||
val currentUser = telegramHelper.getCurrentUser()
|
||||
for (orderedChat in chatList) {
|
||||
val chat = telegramHelper.getChat(orderedChat.chatId)
|
||||
if (chat != null && (chat.id != currentUserId?.toLong())) {
|
||||
if (chat != null) {
|
||||
if (telegramHelper.isPrivateChat(chat)) {
|
||||
if ((chat.type as TdApi.ChatTypePrivate).userId == currentUser?.id) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
chats.add(chat)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue