diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/User.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/User.kt index a1c242923..4dfb4ec30 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/User.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/User.kt @@ -67,7 +67,7 @@ class User( var latestMetadataRelay: String? = null var latestContactList: ContactListEvent? = null var latestBookmarkList: BookmarkListEvent? = null - var followSets: List = listOf() + var followSets: Set = setOf() private set var reports = mapOf>() 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 349caffc0..b52234acb 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 @@ -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 = observeByAuthor(ChatMessageRelayListEvent.KIND, account.signer.pubKey) val searchRelays: StateFlow = observeByAuthor(SearchRelayListEvent.KIND, account.signer.pubKey) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/ProfileActions.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/ProfileActions.kt index 046e6ff85..ed22b129c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/ProfileActions.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/ProfileActions.kt @@ -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