diff --git a/app/src/main/java/io/github/chronosx88/influence/logic/SettingsLogic.kt b/app/src/main/java/io/github/chronosx88/influence/logic/SettingsLogic.kt index e324a34..e0a7899 100644 --- a/app/src/main/java/io/github/chronosx88/influence/logic/SettingsLogic.kt +++ b/app/src/main/java/io/github/chronosx88/influence/logic/SettingsLogic.kt @@ -4,7 +4,9 @@ import android.util.Log import io.github.chronosx88.influence.contracts.CoreContracts import io.github.chronosx88.influence.helpers.AppHelper import io.github.chronosx88.influence.helpers.KeyPairManager +import io.github.chronosx88.influence.helpers.ObservableUtils import io.github.chronosx88.influence.helpers.P2PUtils +import io.github.chronosx88.influence.helpers.actions.UIActions import net.tomp2p.peers.Number640 import net.tomp2p.storage.Data import java.io.IOException @@ -12,6 +14,10 @@ import java.io.IOException class SettingsLogic : CoreContracts.ISettingsLogic { override fun checkUsernameExists(username: String) : Boolean { + if (AppHelper.getPeerDHT() == null) { + ObservableUtils.notifyUI(UIActions.NODE_IS_OFFLINE) + return false + } val usernameMap: MutableMap? = P2PUtils.get(username) usernameMap ?: return false return true @@ -22,6 +28,10 @@ class SettingsLogic : CoreContracts.ISettingsLogic { private val keyPairManager = KeyPairManager() fun publishUsername(oldUsername: String?, username: String?) { + if (AppHelper.getPeerDHT() == null) { + ObservableUtils.notifyUI(UIActions.NODE_IS_OFFLINE) + return + } val mainKeyPair = keyPairManager.openMainKeyPair() oldUsername?.let { if(!oldUsername.equals("")) {