Use better naming for the view models, reflecting their true nature, and preparing for future work here.
This commit is contained in:
@@ -51,7 +51,7 @@ import com.vitorpamplona.amethyst.ui.dal.ThreadFeedFilter
|
|||||||
import com.vitorpamplona.amethyst.ui.feeds.FeedContentState
|
import com.vitorpamplona.amethyst.ui.feeds.FeedContentState
|
||||||
import com.vitorpamplona.amethyst.ui.feeds.FeedState
|
import com.vitorpamplona.amethyst.ui.feeds.FeedState
|
||||||
import com.vitorpamplona.amethyst.ui.feeds.InvalidatableContent
|
import com.vitorpamplona.amethyst.ui.feeds.InvalidatableContent
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.FollowSetFeedViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.NostrListFeedViewModel
|
||||||
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey
|
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
@@ -163,13 +163,13 @@ class NostrBookmarkPrivateFeedViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
class NostrUserFollowSetFeedViewModel(
|
class NostrUserListFeedViewModel(
|
||||||
val account: Account,
|
val account: Account,
|
||||||
) : FollowSetFeedViewModel(FollowSetFeedFilter(account)) {
|
) : NostrListFeedViewModel(FollowSetFeedFilter(account)) {
|
||||||
class Factory(
|
class Factory(
|
||||||
val account: Account,
|
val account: Account,
|
||||||
) : ViewModelProvider.Factory {
|
) : ViewModelProvider.Factory {
|
||||||
override fun <NostrUserFollowSetFeedViewModel : ViewModel> create(modelClass: Class<NostrUserFollowSetFeedViewModel>): NostrUserFollowSetFeedViewModel = NostrUserFollowSetFeedViewModel(account) as NostrUserFollowSetFeedViewModel
|
override fun <NostrUserFollowSetFeedViewModel : ViewModel> create(modelClass: Class<NostrUserFollowSetFeedViewModel>): NostrUserFollowSetFeedViewModel = NostrUserListFeedViewModel(account) as NostrUserFollowSetFeedViewModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -65,7 +65,7 @@ import com.vitorpamplona.amethyst.ui.feeds.LoadingFeed
|
|||||||
import com.vitorpamplona.amethyst.ui.feeds.RefresheableBox
|
import com.vitorpamplona.amethyst.ui.feeds.RefresheableBox
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.INav
|
import com.vitorpamplona.amethyst.ui.navigation.INav
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.TopBarWithBackButton
|
import com.vitorpamplona.amethyst.ui.navigation.TopBarWithBackButton
|
||||||
import com.vitorpamplona.amethyst.ui.screen.NostrUserFollowSetFeedViewModel
|
import com.vitorpamplona.amethyst.ui.screen.NostrUserListFeedViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.DisappearingScaffold
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.DisappearingScaffold
|
||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
@@ -83,10 +83,10 @@ fun ListsScreen(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
val followSetsViewModel: NostrUserFollowSetFeedViewModel =
|
val followSetsViewModel: NostrUserListFeedViewModel =
|
||||||
viewModel(
|
viewModel(
|
||||||
key = "NostrUserFollowSetFeedViewModel",
|
key = "NostrUserListFeedViewModel",
|
||||||
factory = NostrUserFollowSetFeedViewModel.Factory(accountViewModel.account),
|
factory = NostrUserListFeedViewModel.Factory(accountViewModel.account),
|
||||||
)
|
)
|
||||||
|
|
||||||
val currentCoroutineScope = rememberCoroutineScope()
|
val currentCoroutineScope = rememberCoroutineScope()
|
||||||
|
|||||||
+3
-2
@@ -43,7 +43,8 @@ import kotlinx.coroutines.flow.asStateFlow
|
|||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
abstract class FollowSetFeedViewModel(
|
// TODO: Investigate the addition of feed filters, for bookmark sets and general ones.
|
||||||
|
abstract class NostrListFeedViewModel(
|
||||||
val dataSource: FeedFilter<FollowSet>,
|
val dataSource: FeedFilter<FollowSet>,
|
||||||
) : ViewModel(),
|
) : ViewModel(),
|
||||||
InvalidatableContent {
|
InvalidatableContent {
|
||||||
@@ -86,7 +87,7 @@ abstract class FollowSetFeedViewModel(
|
|||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(
|
Log.e(
|
||||||
"FollowSetFeedViewModel",
|
"NostrListFeedViewModel",
|
||||||
"refreshSuspended: Error loading or refreshing feed -> ${e.message}",
|
"refreshSuspended: Error loading or refreshing feed -> ${e.message}",
|
||||||
)
|
)
|
||||||
_feedContent.update { FollowSetState.FeedError(e.message.toString()) }
|
_feedContent.update { FollowSetState.FeedError(e.message.toString()) }
|
||||||
Reference in New Issue
Block a user