Improved version of NostrUserListFeedViewModel. Remove unneeded LaunchedEffect in CustomListsScreen.
This commit is contained in:
-5
@@ -41,7 +41,6 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
@@ -101,10 +100,6 @@ fun ListsScreen(
|
||||
|
||||
val followSetsFlow by followSetsViewModel.feedContent.collectAsStateWithLifecycle()
|
||||
|
||||
LaunchedEffect(followSetsFlow) {
|
||||
followSetsViewModel.invalidateData()
|
||||
}
|
||||
|
||||
// TODO: Replace this with nav-based solution.
|
||||
val isFollowSetSelected = remember { mutableStateOf(false) }
|
||||
val selectedFollowList = remember { mutableStateOf<FollowSet?>(null) }
|
||||
|
||||
+8
-6
@@ -46,6 +46,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.util.UUID
|
||||
|
||||
// TODO Update: Rename this to be used only for follow sets, and create separate VMs for bookmark sets, etc.
|
||||
@@ -62,12 +63,12 @@ class NostrUserListFeedViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun getFollowSetNote(
|
||||
suspend fun getFollowSetNote(
|
||||
noteIdentifier: String,
|
||||
account: Account,
|
||||
): AddressableNote? {
|
||||
checkNotInMainThread()
|
||||
val potentialNote = account.userProfile().followSetNotes.find { it.dTag() == noteIdentifier }
|
||||
val potentialNote = account.getFollowSetNotes().find { it.dTag() == noteIdentifier }
|
||||
return potentialNote
|
||||
}
|
||||
|
||||
@@ -77,9 +78,7 @@ class NostrUserListFeedViewModel(
|
||||
): Boolean {
|
||||
checkNotInMainThread()
|
||||
val potentialNote =
|
||||
account
|
||||
.userProfile()
|
||||
.followSetNotes
|
||||
runBlocking(viewModelScope.coroutineContext) { account.getFollowSetNotes() }
|
||||
.find { (it.event as PeopleListEvent).nameOrTitle() == setName }
|
||||
return potentialNote != null
|
||||
}
|
||||
@@ -264,6 +263,9 @@ class NostrUserListFeedViewModel(
|
||||
class Factory(
|
||||
val account: Account,
|
||||
) : ViewModelProvider.Factory {
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T = NostrUserListFeedViewModel(FollowSetFeedFilter(account)) as T
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T =
|
||||
NostrUserListFeedViewModel(
|
||||
FollowSetFeedFilter(account),
|
||||
) as T
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user