This commit is contained in:
Dmitriy Ruban 2020-01-08 17:18:38 +02:00
parent 61863cf746
commit 73bf590cc5

View file

@ -155,7 +155,7 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch
} }
private fun runSearch(text: String) { private fun runSearch(text: String) {
if (getString(R.string.saved_messages).startsWith(text, true)) { if (getSavedMessagesChatTitle().startsWith(text, true)) {
val savedMessages = telegramHelper.getChat(telegramHelper.getCurrentUserId().toLong()) val savedMessages = telegramHelper.getChat(telegramHelper.getCurrentUserId().toLong())
if (savedMessages != null) { if (savedMessages != null) {
telegramHelper.searchChats(savedMessages.title) telegramHelper.searchChats(savedMessages.title)
@ -164,11 +164,13 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch
telegramHelper.searchChats(text) telegramHelper.searchChats(text)
telegramHelper.searchChatsOnServer(text) telegramHelper.searchChatsOnServer(text)
telegramHelper.searchContacts(text) telegramHelper.searchContacts(text)
if (text.length > 4 && !getString(R.string.saved_messages).startsWith(text, true)) { if (text.length > 4 && !getSavedMessagesChatTitle().startsWith(text, true)) {
telegramHelper.searchPublicChats(text) telegramHelper.searchPublicChats(text)
} }
} }
private fun getSavedMessagesChatTitle() = getString(R.string.saved_messages)
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
telegramHelper.addSearchListener(this) telegramHelper.addSearchListener(this)
@ -392,13 +394,13 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch
val title = when (item) { val title = when (item) {
is TdApi.Chat -> { is TdApi.Chat -> {
if (telegramHelper.isPrivateChat(item) && (item.type as TdApi.ChatTypePrivate).userId == currentUserId) { if (telegramHelper.isPrivateChat(item) && (item.type as TdApi.ChatTypePrivate).userId == currentUserId) {
getString(R.string.saved_messages) getSavedMessagesChatTitle()
} else { } else {
item.title item.title
} }
} }
is TdApi.User -> { is TdApi.User -> {
if (item.id == currentUserId) getString(R.string.saved_messages) else TelegramUiHelper.getUserName(item) if (item.id == currentUserId) getSavedMessagesChatTitle() else TelegramUiHelper.getUserName(item)
} }
else -> null else -> null
} }