Rename FollowList ViewModel to match it's actual use.
This commit is contained in:
@@ -23,30 +23,15 @@ package com.vitorpamplona.amethyst.ui.screen
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.ui.dal.FeedFilter
|
import com.vitorpamplona.amethyst.ui.dal.FeedFilter
|
||||||
import com.vitorpamplona.amethyst.ui.dal.FollowSetFeedFilter
|
|
||||||
import com.vitorpamplona.amethyst.ui.feeds.FeedContentState
|
import com.vitorpamplona.amethyst.ui.feeds.FeedContentState
|
||||||
import com.vitorpamplona.amethyst.ui.feeds.InvalidatableContent
|
import com.vitorpamplona.amethyst.ui.feeds.InvalidatableContent
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.NostrListFeedViewModel
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Stable
|
|
||||||
class NostrUserListFeedViewModel(
|
|
||||||
val account: Account,
|
|
||||||
) : NostrListFeedViewModel(FollowSetFeedFilter(account)) {
|
|
||||||
class Factory(
|
|
||||||
val account: Account,
|
|
||||||
) : ViewModelProvider.Factory {
|
|
||||||
override fun <NostrUserFollowSetFeedViewModel : ViewModel> create(modelClass: Class<NostrUserFollowSetFeedViewModel>): NostrUserFollowSetFeedViewModel = NostrUserListFeedViewModel(account) as NostrUserFollowSetFeedViewModel
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
abstract class FeedViewModel(
|
abstract class FeedViewModel(
|
||||||
localFilter: FeedFilter<Note>,
|
localFilter: FeedFilter<Note>,
|
||||||
|
|||||||
+2
-2
@@ -77,10 +77,10 @@ fun ListsScreen(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
val followSetsViewModel: NostrListFeedViewModel =
|
val followSetsViewModel: NostrUserListFeedViewModel =
|
||||||
viewModel(
|
viewModel(
|
||||||
key = "NostrUserListFeedViewModel",
|
key = "NostrUserListFeedViewModel",
|
||||||
factory = NostrListFeedViewModel.Factory(accountViewModel.account),
|
factory = NostrUserListFeedViewModel.Factory(accountViewModel.account),
|
||||||
)
|
)
|
||||||
|
|
||||||
val currentCoroutineScope = rememberCoroutineScope()
|
val currentCoroutineScope = rememberCoroutineScope()
|
||||||
|
|||||||
+4
-4
@@ -48,8 +48,8 @@ import kotlinx.coroutines.flow.update
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
// TODO: Investigate the addition of feed filters, for bookmark sets and general ones.
|
// TODO Update: Rename this to be used only for follow sets, and create separate VMs for bookmark sets, etc.
|
||||||
class NostrListFeedViewModel(
|
class NostrUserListFeedViewModel(
|
||||||
val dataSource: FeedFilter<FollowSet>,
|
val dataSource: FeedFilter<FollowSet>,
|
||||||
) : ViewModel(),
|
) : ViewModel(),
|
||||||
InvalidatableContent {
|
InvalidatableContent {
|
||||||
@@ -105,7 +105,7 @@ class NostrListFeedViewModel(
|
|||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(
|
Log.e(
|
||||||
"NostrListFeedViewModel",
|
"NostrUserListFeedViewModel",
|
||||||
"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()) }
|
||||||
@@ -264,6 +264,6 @@ class NostrListFeedViewModel(
|
|||||||
class Factory(
|
class Factory(
|
||||||
val account: Account,
|
val account: Account,
|
||||||
) : ViewModelProvider.Factory {
|
) : ViewModelProvider.Factory {
|
||||||
override fun <T : ViewModel> create(modelClass: Class<T>): T = NostrListFeedViewModel(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