mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 10:56:48 +01:00
Removes the Mute List from the All Follows TopNav option
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,10 +94,20 @@ class PeopleListsState(
|
||||
|
||||
suspend fun List<PeopleListEvent>.mapToUserIdSet() = this.map { it.userIdSet() }.flattenToSet()
|
||||
|
||||
val allPeopleListProfiles: StateFlow<Set<HexKey>> =
|
||||
suspend fun List<PeopleListEvent>.mapGoodUsersToIdSet() =
|
||||
this
|
||||
.mapNotNull {
|
||||
if (it.dTag() != PeopleListEvent.BLOCK_LIST_D_TAG) {
|
||||
it.userIdSet()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}.flattenToSet()
|
||||
|
||||
val allGoodPeopleListProfiles: StateFlow<Set<HexKey>> =
|
||||
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<Note>): Boolean =
|
||||
|
||||
@@ -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<String>,
|
||||
peopleListProfiles: Set<String>,
|
||||
followListProfiles: Set<String>,
|
||||
hashtags: Set<String>,
|
||||
geohashes: Set<String>,
|
||||
community: Set<CommunityTag>,
|
||||
): 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<AllFollows> =
|
||||
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<HexKey>,
|
||||
args[2] as Set<HexKey>,
|
||||
args[3] as Set<String>,
|
||||
args[4] as Set<String>,
|
||||
args[5] as Set<CommunityTag>,
|
||||
)
|
||||
}.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,
|
||||
|
||||
@@ -148,14 +148,14 @@ class TopNavFilterState(
|
||||
|
||||
val livePeopleListsFlow: Flow<List<FeedDefinition>> =
|
||||
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,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user