From 59cdb222d5a2e0486f21a86e9d4e09455bbba5ff Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 5 Nov 2025 10:51:10 -0500 Subject: [PATCH] Removes the Mute List from the All Follows TopNav option --- .../vitorpamplona/amethyst/model/Account.kt | 14 +++---- .../nip51Lists/peopleList/PeopleListsState.kt | 18 +++++--- .../serverList/MergedFollowListsState.kt | 41 +++++++++++++------ .../amethyst/ui/screen/TopNavFilterState.kt | 8 ++-- .../lists/display/PeopleListViewModel.kt | 10 ++--- .../lists/list/ListOfPeopleListsScreen.kt | 12 +++--- .../lists/memberEdit/EditPeopleListScreen.kt | 8 ++-- 7 files changed, 68 insertions(+), 43 deletions(-) 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 794a38bc1..25b8f346c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -286,8 +286,8 @@ class Account( val peopleListDecryptionCache = PeopleListDecryptionCache(signer) val blockPeopleList = BlockPeopleListState(signer, cache, peopleListDecryptionCache, scope) - val peopleListsState = PeopleListsState(signer, cache, peopleListDecryptionCache, scope) - val followListsState = FollowListsState(signer, cache, scope) + val peopleLists = PeopleListsState(signer, cache, peopleListDecryptionCache, scope) + val followLists = FollowListsState(signer, cache, scope) val hiddenUsers = HiddenUsersState(muteList.flow, blockPeopleList.flow, scope, settings) @@ -325,7 +325,7 @@ class Account( val followsPerRelay = FollowsPerOutboxRelay(kind3FollowList, blockedRelayList, proxyRelayList, cache, scope).flow // Merges all follow lists to create a single All Follows feed. - val allFollows = MergedFollowListsState(kind3FollowList, peopleListsState, hashtagList, geohashList, communityList, scope) + val allFollows = MergedFollowListsState(kind3FollowList, peopleLists, followLists, hashtagList, geohashList, communityList, scope) val privateDMDecryptionCache = PrivateDMCache(signer) val privateZapsDecryptionCache = PrivateZapCache(signer) @@ -1780,8 +1780,8 @@ class Account( logTime("Account ${userProfile().toBestDisplayName()} newEventBundle Update with ${newNotes.size} new notes") { upgradeAttestations() newNotesPreProcessor.runNew(newNotes) - peopleListsState.newNotes(newNotes) - followListsState.newNotes(newNotes) + peopleLists.newNotes(newNotes) + followLists.newNotes(newNotes) } } } @@ -1790,8 +1790,8 @@ class Account( cache.live.deletedEventBundles.collect { deletedNotes -> logTime("Account ${userProfile().toBestDisplayName()} deletedEventBundle Update with ${deletedNotes.size} new notes") { newNotesPreProcessor.runDeleted(deletedNotes) - peopleListsState.deletedNotes(deletedNotes) - followListsState.deletedNotes(deletedNotes) + peopleLists.deletedNotes(deletedNotes) + followLists.deletedNotes(deletedNotes) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/PeopleListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/PeopleListsState.kt index 47bce8c59..1244d611b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/PeopleListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/PeopleListsState.kt @@ -94,10 +94,20 @@ class PeopleListsState( suspend fun List.mapToUserIdSet() = this.map { it.userIdSet() }.flattenToSet() - val allPeopleListProfiles: StateFlow> = + suspend fun List.mapGoodUsersToIdSet() = + this + .mapNotNull { + if (it.dTag() != PeopleListEvent.BLOCK_LIST_D_TAG) { + it.userIdSet() + } else { + null + } + }.flattenToSet() + + val allGoodPeopleListProfiles: StateFlow> = latestLists - .map { it.mapToUserIdSet() } - .onStart { emit(latestLists.value.mapToUserIdSet()) } + .map { it.mapGoodUsersToIdSet() } + .onStart { emit(latestLists.value.mapGoodUsersToIdSet()) } .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptySet()) @@ -131,8 +141,6 @@ class PeopleListsState( ) } - fun isUserInFollowSets(user: User): Boolean = allPeopleListProfiles.value.contains(user.pubkeyHex) - fun DeletionEvent.hasDeletedAnyPeopleList() = deleteAddressesWithKind(PeopleListEvent.KIND) || deletesAnyEventIn(peopleListsEventIds.value) fun hasItemInNoteList(notes: Set): Boolean = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt index 78f1461ce..c9434c50b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt @@ -24,8 +24,10 @@ import androidx.compose.runtime.Immutable import com.vitorpamplona.amethyst.model.nip02FollowLists.Kind3FollowListState import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListState import com.vitorpamplona.amethyst.model.nip51Lists.hashtagLists.HashtagListState +import com.vitorpamplona.amethyst.model.nip51Lists.peopleList.FollowListsState import com.vitorpamplona.amethyst.model.nip51Lists.peopleList.PeopleListsState import com.vitorpamplona.amethyst.model.nip72Communities.CommunityListState +import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip72ModCommunities.follow.tags.CommunityTag import com.vitorpamplona.quartz.nip73ExternalIds.location.GeohashId import com.vitorpamplona.quartz.nip73ExternalIds.topics.HashtagId @@ -41,7 +43,8 @@ import kotlinx.coroutines.flow.stateIn class MergedFollowListsState( val kind3List: Kind3FollowListState, - val followSetList: PeopleListsState, + val peopleList: PeopleListsState, + val followList: FollowListsState, val hashtagList: HashtagListState, val geohashList: GeohashListState, val communityList: CommunityListState, @@ -63,13 +66,14 @@ class MergedFollowListsState( fun mergeLists( kind3: Kind3FollowListState.Kind3Follows, - followSetProfiles: Set, + peopleListProfiles: Set, + followListProfiles: Set, hashtags: Set, geohashes: Set, community: Set, ): AllFollows = AllFollows( - authors = kind3.authors + followSetProfiles, + authors = kind3.authors + peopleListProfiles + followListProfiles, hashtags = hashtags, geotags = geohashes, communities = community.mapTo(mutableSetOf()) { it.address.toValue() }, @@ -77,17 +81,29 @@ class MergedFollowListsState( val flow: StateFlow = combine( - kind3List.flow, - followSetList.allPeopleListProfiles, - hashtagList.flow, - geohashList.flow, - communityList.flow, - ::mergeLists, - ).onStart { + listOf( + kind3List.flow, + peopleList.allGoodPeopleListProfiles, + followList.allPeopleListProfiles, + hashtagList.flow, + geohashList.flow, + communityList.flow, + ), + ) { args -> + mergeLists( + args[0] as Kind3FollowListState.Kind3Follows, + args[1] as Set, + args[2] as Set, + args[3] as Set, + args[4] as Set, + args[5] as Set, + ) + }.onStart { emit( mergeLists( kind3List.flow.value, - followSetList.allPeopleListProfiles.value, + peopleList.allGoodPeopleListProfiles.value, + followList.allPeopleListProfiles.value, hashtagList.flow.value, geohashList.flow.value, communityList.flow.value, @@ -100,7 +116,8 @@ class MergedFollowListsState( SharingStarted.Eagerly, mergeLists( kind3List.flow.value, - followSetList.allPeopleListProfiles.value, + peopleList.allGoodPeopleListProfiles.value, + followList.allPeopleListProfiles.value, hashtagList.flow.value, geohashList.flow.value, communityList.flow.value, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt index c3d257757..3d6f89fc1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt @@ -148,14 +148,14 @@ class TopNavFilterState( val livePeopleListsFlow: Flow> = combine( - account.peopleListsState.peopleListNotes, - account.followListsState.followListNotes, + account.peopleLists.peopleListNotes, + account.followLists.followListNotes, ::mergePeopleLists, ).onStart { emit( mergePeopleLists( - account.peopleListsState.peopleListNotes.value, - account.followListsState.followListNotes.value, + account.peopleLists.peopleListNotes.value, + account.followLists.followListNotes.value, ), ) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/PeopleListViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/PeopleListViewModel.kt index 3a967980f..d36a0fb86 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/PeopleListViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/PeopleListViewModel.kt @@ -55,7 +55,7 @@ class PeopleListViewModel : ViewModel() { selectedDTag .transformLatest { emitAll( - account.peopleListsState.selectListFlow(it).flowOn(Dispatchers.IO), + account.peopleLists.selectListFlow(it).flowOn(Dispatchers.IO), ) }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), null) @@ -73,23 +73,23 @@ class PeopleListViewModel : ViewModel() { } suspend fun deleteFollowSet() { - account.peopleListsState.deleteFollowSet(selectedDTag.value, account) + account.peopleLists.deleteFollowSet(selectedDTag.value, account) } - fun loadNote(): AddressableNote? = account.peopleListsState.getPeopleListNote(selectedDTag.value) + fun loadNote(): AddressableNote? = account.peopleLists.getPeopleListNote(selectedDTag.value) suspend fun removeUserFromSet( user: User, isPrivate: Boolean, ) { - account.peopleListsState.removeUserFromSet(user, isPrivate, selectedDTag.value, account) + account.peopleLists.removeUserFromSet(user, isPrivate, selectedDTag.value, account) } suspend fun addUserToSet( user: User, isPrivate: Boolean, ) { - account.peopleListsState.addUserToSet(user, selectedDTag.value, isPrivate, account) + account.peopleLists.addUserToSet(user, selectedDTag.value, isPrivate, account) } fun hasUserFlow( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/ListOfPeopleListsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/ListOfPeopleListsScreen.kt index 40dc823dd..24becb801 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/ListOfPeopleListsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/ListOfPeopleListsScreen.kt @@ -61,10 +61,10 @@ fun ListOfPeopleListsScreen( nav: INav, ) { ListOfPeopleListsScreen( - listFlow = accountViewModel.account.peopleListsState.uiListFlow, + listFlow = accountViewModel.account.peopleLists.uiListFlow, addItem = { title: String, description: String? -> accountViewModel.runIOCatching { - accountViewModel.account.peopleListsState.addFollowList( + accountViewModel.account.peopleLists.addFollowList( listName = title, listDescription = description, account = accountViewModel.account, @@ -76,7 +76,7 @@ fun ListOfPeopleListsScreen( }, renameItem = { followSet, newValue -> accountViewModel.runIOCatching { - accountViewModel.account.peopleListsState.renameFollowList( + accountViewModel.account.peopleLists.renameFollowList( newName = newValue, peopleList = followSet, account = accountViewModel.account, @@ -85,7 +85,7 @@ fun ListOfPeopleListsScreen( }, changeItemDescription = { followSet, newDescription -> accountViewModel.runIOCatching { - accountViewModel.account.peopleListsState.modifyFollowSetDescription( + accountViewModel.account.peopleLists.modifyFollowSetDescription( newDescription = newDescription, peopleList = followSet, account = accountViewModel.account, @@ -94,7 +94,7 @@ fun ListOfPeopleListsScreen( }, cloneItem = { followSet, customName, customDescription -> accountViewModel.runIOCatching { - accountViewModel.account.peopleListsState.cloneFollowSet( + accountViewModel.account.peopleLists.cloneFollowSet( currentPeopleList = followSet, customCloneName = customName, customCloneDescription = customDescription, @@ -104,7 +104,7 @@ fun ListOfPeopleListsScreen( }, deleteItem = { followSet -> accountViewModel.runIOCatching { - accountViewModel.account.peopleListsState.deleteFollowSet( + accountViewModel.account.peopleLists.deleteFollowSet( identifierTag = followSet.identifierTag, account = accountViewModel.account, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/EditPeopleListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/EditPeopleListScreen.kt index 172a3a2d8..609de3ebe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/EditPeopleListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/EditPeopleListScreen.kt @@ -150,7 +150,7 @@ private fun FollowSetManagementScreenBody( accountViewModel: AccountViewModel, nav: INav, ) { - val followSetsState by accountViewModel.account.peopleListsState.uiListFlow + val followSetsState by accountViewModel.account.peopleLists.uiListFlow .collectAsStateWithLifecycle() if (followSetsState.isEmpty()) { @@ -168,7 +168,7 @@ private fun FollowSetManagementScreenBody( userIsPublicMember = list.publicMembers.contains(userToAddOrRemove), onRemoveUser = { accountViewModel.runIOCatching { - accountViewModel.account.peopleListsState.removeUserFromSet( + accountViewModel.account.peopleLists.removeUserFromSet( userToAddOrRemove, isPrivate = list.privateMembers.contains(userToAddOrRemove), list.identifierTag, @@ -178,7 +178,7 @@ private fun FollowSetManagementScreenBody( }, onAddUserToList = { userShouldBePrivate -> accountViewModel.runIOCatching { - accountViewModel.account.peopleListsState.addUserToSet( + accountViewModel.account.peopleLists.addUserToSet( userToAddOrRemove, list.identifierTag, userShouldBePrivate, @@ -196,7 +196,7 @@ private fun FollowSetManagementScreenBody( userName = userToAddOrRemove.toBestDisplayName(), onSetCreate = { setName, memberShouldBePrivate, description -> accountViewModel.runIOCatching { - accountViewModel.account.peopleListsState.addFollowList( + accountViewModel.account.peopleLists.addFollowList( listName = setName, listDescription = description, isPrivate = memberShouldBePrivate,