Use Set rather than List, to avoid duplication. Introduce follow sets flow, and use it in FollowSetsActionMenu.
This commit is contained in:
@@ -67,7 +67,7 @@ class User(
|
||||
var latestMetadataRelay: String? = null
|
||||
var latestContactList: ContactListEvent? = null
|
||||
var latestBookmarkList: BookmarkListEvent? = null
|
||||
var followSets: List<AddressableNote> = listOf()
|
||||
var followSets: Set<AddressableNote> = setOf()
|
||||
private set
|
||||
|
||||
var reports = mapOf<User, Set<Note>>()
|
||||
|
||||
+18
@@ -166,6 +166,24 @@ class AccountViewModel(
|
||||
emptySet(),
|
||||
)
|
||||
|
||||
val followSetsFlow =
|
||||
account
|
||||
.userProfile()
|
||||
.flow()
|
||||
.followSets.stateFlow
|
||||
.map { followSetsState ->
|
||||
checkNotInMainThread()
|
||||
account.getFollowSetNotes()
|
||||
followSetsState.user.followSets.map {
|
||||
account.mapNoteToFollowSet(it)
|
||||
}
|
||||
}.flowOn(Dispatchers.Default)
|
||||
.stateIn(
|
||||
viewModelScope,
|
||||
SharingStarted.WhileSubscribed(10000, 10000),
|
||||
emptyList(),
|
||||
)
|
||||
|
||||
val dmRelays: StateFlow<ChatMessageRelayListEvent?> = observeByAuthor(ChatMessageRelayListEvent.KIND, account.signer.pubKey)
|
||||
val searchRelays: StateFlow<SearchRelayListEvent?> = observeByAuthor(SearchRelayListEvent.KIND, account.signer.pubKey)
|
||||
|
||||
|
||||
+3
-1
@@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.header
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
@@ -39,6 +40,7 @@ fun ProfileActions(
|
||||
nav: INav,
|
||||
) {
|
||||
val tempFollowLists = remember { generateFollowLists().toMutableStateList() }
|
||||
val actualFollowLists by accountViewModel.followSetsFlow.collectAsState()
|
||||
val isMe by
|
||||
remember(accountViewModel) { derivedStateOf { accountViewModel.userProfile() == baseUser } }
|
||||
|
||||
@@ -56,7 +58,7 @@ fun ProfileActions(
|
||||
|
||||
FollowSetsActionMenu(
|
||||
userHex = baseUser.pubkeyHex,
|
||||
followLists = tempFollowLists,
|
||||
followLists = actualFollowLists,
|
||||
addUser = { index, list ->
|
||||
Log.d("Amethyst", "ProfileActions: Updating list ...")
|
||||
val newList = tempFollowLists[index].profileList + baseUser.pubkeyHex
|
||||
|
||||
Reference in New Issue
Block a user