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.material3.TextField
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
@@ -101,10 +100,6 @@ fun ListsScreen(
|
|||||||
|
|
||||||
val followSetsFlow by followSetsViewModel.feedContent.collectAsStateWithLifecycle()
|
val followSetsFlow by followSetsViewModel.feedContent.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
LaunchedEffect(followSetsFlow) {
|
|
||||||
followSetsViewModel.invalidateData()
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Replace this with nav-based solution.
|
// TODO: Replace this with nav-based solution.
|
||||||
val isFollowSetSelected = remember { mutableStateOf(false) }
|
val isFollowSetSelected = remember { mutableStateOf(false) }
|
||||||
val selectedFollowList = remember { mutableStateOf<FollowSet?>(null) }
|
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.asStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
// TODO Update: Rename this to be used only for follow sets, and create separate VMs for bookmark sets, etc.
|
// 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,
|
noteIdentifier: String,
|
||||||
account: Account,
|
account: Account,
|
||||||
): AddressableNote? {
|
): AddressableNote? {
|
||||||
checkNotInMainThread()
|
checkNotInMainThread()
|
||||||
val potentialNote = account.userProfile().followSetNotes.find { it.dTag() == noteIdentifier }
|
val potentialNote = account.getFollowSetNotes().find { it.dTag() == noteIdentifier }
|
||||||
return potentialNote
|
return potentialNote
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,9 +78,7 @@ class NostrUserListFeedViewModel(
|
|||||||
): Boolean {
|
): Boolean {
|
||||||
checkNotInMainThread()
|
checkNotInMainThread()
|
||||||
val potentialNote =
|
val potentialNote =
|
||||||
account
|
runBlocking(viewModelScope.coroutineContext) { account.getFollowSetNotes() }
|
||||||
.userProfile()
|
|
||||||
.followSetNotes
|
|
||||||
.find { (it.event as PeopleListEvent).nameOrTitle() == setName }
|
.find { (it.event as PeopleListEvent).nameOrTitle() == setName }
|
||||||
return potentialNote != null
|
return potentialNote != null
|
||||||
}
|
}
|
||||||
@@ -264,6 +263,9 @@ class NostrUserListFeedViewModel(
|
|||||||
class Factory(
|
class Factory(
|
||||||
val account: Account,
|
val account: Account,
|
||||||
) : ViewModelProvider.Factory {
|
) : 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