mirror of
https://github.com/ChronosX88/Influence-P2P.git
synced 2024-11-21 15:02:17 +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.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<Number640, Data>? = 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("")) {
|
||||
|
Loading…
Reference in New Issue
Block a user