mirror of
https://github.com/ChronosX88/Influence-P2P.git
synced 2024-11-22 07:12:19 +00:00
Fixed issue when changing username when node is offline.
This commit is contained in:
parent
58ed8aef78
commit
8c95351b03
@ -4,7 +4,9 @@ import android.util.Log
|
|||||||
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.KeyPairManager
|
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.P2PUtils
|
||||||
|
import io.github.chronosx88.influence.helpers.actions.UIActions
|
||||||
import net.tomp2p.peers.Number640
|
import net.tomp2p.peers.Number640
|
||||||
import net.tomp2p.storage.Data
|
import net.tomp2p.storage.Data
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@ -12,6 +14,10 @@ import java.io.IOException
|
|||||||
class SettingsLogic : CoreContracts.ISettingsLogic {
|
class SettingsLogic : CoreContracts.ISettingsLogic {
|
||||||
|
|
||||||
override fun checkUsernameExists(username: String) : Boolean {
|
override fun checkUsernameExists(username: String) : Boolean {
|
||||||
|
if (AppHelper.getPeerDHT() == null) {
|
||||||
|
ObservableUtils.notifyUI(UIActions.NODE_IS_OFFLINE)
|
||||||
|
return false
|
||||||
|
}
|
||||||
val usernameMap: MutableMap<Number640, Data>? = P2PUtils.get(username)
|
val usernameMap: MutableMap<Number640, Data>? = P2PUtils.get(username)
|
||||||
usernameMap ?: return false
|
usernameMap ?: return false
|
||||||
return true
|
return true
|
||||||
@ -22,6 +28,10 @@ class SettingsLogic : CoreContracts.ISettingsLogic {
|
|||||||
private val keyPairManager = KeyPairManager()
|
private val keyPairManager = KeyPairManager()
|
||||||
|
|
||||||
fun publishUsername(oldUsername: String?, username: String?) {
|
fun publishUsername(oldUsername: String?, username: String?) {
|
||||||
|
if (AppHelper.getPeerDHT() == null) {
|
||||||
|
ObservableUtils.notifyUI(UIActions.NODE_IS_OFFLINE)
|
||||||
|
return
|
||||||
|
}
|
||||||
val mainKeyPair = keyPairManager.openMainKeyPair()
|
val mainKeyPair = keyPairManager.openMainKeyPair()
|
||||||
oldUsername?.let {
|
oldUsername?.let {
|
||||||
if(!oldUsername.equals("")) {
|
if(!oldUsername.equals("")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user