Added checking interlocutor's JID before saving chat

This commit is contained in:
ChronosX88 2019-05-23 21:00:18 +04:00
parent 77c97cf012
commit 65bb540110
3 changed files with 8 additions and 1 deletions

View File

@ -17,6 +17,7 @@
package io.github.chronosx88.influence.presenters package io.github.chronosx88.influence.presenters
import android.content.Intent import android.content.Intent
import io.github.chronosx88.influence.R
import io.github.chronosx88.influence.contracts.CoreContracts import io.github.chronosx88.influence.contracts.CoreContracts
import io.github.chronosx88.influence.helpers.AppHelper import io.github.chronosx88.influence.helpers.AppHelper
import io.github.chronosx88.influence.helpers.LocalDBWrapper import io.github.chronosx88.influence.helpers.LocalDBWrapper
@ -36,7 +37,11 @@ class MainPresenter(private val view: CoreContracts.IMainViewContract) : CoreCon
} }
override fun startChatWithPeer(username: String) { override fun startChatWithPeer(username: String) {
LocalDBWrapper.createChatEntry(username, username) if(!username.contains("@")) {
view.showSnackbar(AppHelper.getContext().getString(R.string.invalid_jid_error))
return
}
LocalDBWrapper.createChatEntry(username, username.split("@")[0])
EventBus.getDefault().post(NewChatEvent(username)) EventBus.getDefault().post(NewChatEvent(username))
} }

View File

@ -23,4 +23,5 @@
<string name="hint_enter_a_message">Введите сообщение...</string> <string name="hint_enter_a_message">Введите сообщение...</string>
<string name="logout">Выйти из аккаунта</string> <string name="logout">Выйти из аккаунта</string>
<string name="sign_in_button">Войти</string> <string name="sign_in_button">Войти</string>
<string name="invalid_jid_error">Неверный JabberID!</string>
</resources> </resources>

View File

@ -22,4 +22,5 @@
<string name="hint_enter_a_message">Enter message...</string> <string name="hint_enter_a_message">Enter message...</string>
<string name="logout">Log out from account</string> <string name="logout">Log out from account</string>
<string name="sign_in_button">Sign In</string> <string name="sign_in_button">Sign In</string>
<string name="invalid_jid_error">Invalid JabberID!</string>
</resources> </resources>