diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index 364e675fe..211a07b70 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -431,7 +431,7 @@ class Account( emit( LiveFollowLists( verifiedFollowingUsers, - verifiedFollowingUsers + keyPair.pubKeyHex, + verifiedFollowingUsers + signer.pubKey, it.user.latestContactList ?.unverifiedFollowTagSet() ?.map { it.lowercase() } @@ -446,7 +446,7 @@ class Account( ) } - val liveKind3Follows = liveKind3FollowsFlow.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex))) + val liveKind3Follows = liveKind3FollowsFlow.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(signer.pubKey))) @OptIn(ExperimentalCoroutinesApi::class) private val liveHomeList: Flow = @@ -477,11 +477,11 @@ class Account( } else if (peopleListFollows.listName == KIND3_FOLLOWS) { emit(kind3Follows) } else if (peopleListFollows.event == null) { - emit(LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex))) + emit(LiveFollowLists(usersPlusMe = setOf(signer.pubKey))) } else { val result = waitToDecrypt(peopleListFollows.event) if (result == null) { - emit(LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex))) + emit(LiveFollowLists(usersPlusMe = setOf(signer.pubKey))) } else { emit(result) } @@ -493,7 +493,7 @@ class Account( } val liveHomeFollowLists: StateFlow by lazy { - liveHomeFollowListFlow.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex))) + liveHomeFollowListFlow.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(signer.pubKey))) } /** @@ -605,7 +605,7 @@ class Account( val liveNotificationFollowLists: StateFlow by lazy { combinePeopleListFlows(liveKind3FollowsFlow, liveNotificationList) - .stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex))) + .stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(signer.pubKey))) } @OptIn(ExperimentalCoroutinesApi::class) @@ -617,7 +617,7 @@ class Account( val liveStoriesFollowLists: StateFlow by lazy { combinePeopleListFlows(liveKind3FollowsFlow, liveStoriesList) - .stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex))) + .stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(signer.pubKey))) } @OptIn(ExperimentalCoroutinesApi::class) @@ -654,7 +654,7 @@ class Account( val liveDiscoveryFollowLists: StateFlow by lazy { combinePeopleListFlows(liveKind3FollowsFlow, liveDiscoveryList) - .stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex))) + .stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(signer.pubKey))) } @OptIn(ExperimentalCoroutinesApi::class) @@ -877,7 +877,7 @@ class Account( suspend fun countFollowersOf(pubkey: HexKey): Int = LocalCache.users.count { _, it -> it.latestContactList?.isTaggedUser(pubkey) ?: false } - suspend fun followerCount(): Int = countFollowersOf(keyPair.pubKeyHex) + suspend fun followerCount(): Int = countFollowersOf(signer.pubKey) fun sendNewUserMetadata( name: String? = null, @@ -3175,7 +3175,7 @@ class Account( } } - fun getAllPeopleLists(): List = getAllPeopleLists(keyPair.pubKeyHex) + fun getAllPeopleLists(): List = getAllPeopleLists(signer.pubKey) fun getAllPeopleLists(pubkey: HexKey): List = LocalCache.addressables diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index aa51112ca..c70ff789a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -804,7 +804,9 @@ class AccountViewModel( viewModelScope.launch(Dispatchers.IO) { account.hideWord(word) } } - fun isLoggedUser(user: User?): Boolean = account.userProfile().pubkeyHex == user?.pubkeyHex + fun isLoggedUser(pubkeyHex: HexKey?): Boolean = account.signer.pubKey == pubkeyHex + + fun isLoggedUser(user: User?): Boolean = isLoggedUser(user?.pubkeyHex) fun isFollowing(user: User?): Boolean { if (user == null) return false diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/crypto/KeyPair.kt b/quartz/src/main/java/com/vitorpamplona/quartz/crypto/KeyPair.kt index 0b696fa52..d6390abc2 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/crypto/KeyPair.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/crypto/KeyPair.kt @@ -20,7 +20,6 @@ */ package com.vitorpamplona.quartz.crypto -import com.vitorpamplona.quartz.encoders.HexKey import com.vitorpamplona.quartz.encoders.toHexKey class KeyPair( @@ -30,7 +29,6 @@ class KeyPair( ) { val privKey: ByteArray? val pubKey: ByteArray - val pubKeyHex: HexKey init { if (privKey == null) { @@ -54,8 +52,6 @@ class KeyPair( this.pubKey = pubKey } } - - this.pubKeyHex = this.pubKey.toHexKey().intern() } override fun toString(): String = "KeyPair(privateKey=${privKey?.toHexKey()}, publicKey=${pubKey.toHexKey()}"