pref: 令 ViewModel 为 @Stable 类型
This commit is contained in:
parent
598c019a26
commit
5249723790
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.editprofile.viewmodel
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.interfaces.ITiebaApi
|
||||
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorCode
|
||||
|
|
@ -17,6 +18,7 @@ import kotlinx.coroutines.FlowPreview
|
|||
import kotlinx.coroutines.flow.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class EditProfileViewModel @Inject constructor() :
|
||||
BaseViewModel<EditProfileIntent, EditProfilePartialChange, EditProfileState, EditProfileEvent>() {
|
||||
|
|
@ -113,24 +115,30 @@ class EditProfileViewModel @Inject constructor() :
|
|||
false,
|
||||
message = partialChange.error
|
||||
)
|
||||
|
||||
EditProfilePartialChange.Submit.Success -> EditProfileEvent.Submit.Result(
|
||||
true,
|
||||
changed = false
|
||||
)
|
||||
|
||||
EditProfilePartialChange.Submit.SuccessWithoutChange -> EditProfileEvent.Submit.Result(
|
||||
true
|
||||
)
|
||||
|
||||
EditProfilePartialChange.ModifyNickname.Start -> EditProfileEvent.ModifyNickname.Start
|
||||
is EditProfilePartialChange.ModifyNickname.Finish -> EditProfileEvent.ModifyNickname.Finish(
|
||||
partialChange.result
|
||||
)
|
||||
|
||||
EditProfilePartialChange.UploadPortrait.Start -> EditProfileEvent.UploadPortrait.Pick
|
||||
is EditProfilePartialChange.UploadPortrait.Success -> EditProfileEvent.UploadPortrait.Success(
|
||||
partialChange.message
|
||||
)
|
||||
|
||||
is EditProfilePartialChange.UploadPortrait.Fail -> EditProfileEvent.UploadPortrait.Fail(
|
||||
partialChange.error
|
||||
)
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.forum
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.CommonResponse
|
||||
import com.huanchengfly.tieba.post.api.models.LikeForumResultBean
|
||||
|
|
@ -24,6 +25,7 @@ import kotlinx.coroutines.flow.merge
|
|||
import kotlinx.coroutines.flow.onStart
|
||||
import javax.inject.Inject
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class ForumViewModel @Inject constructor() :
|
||||
BaseViewModel<ForumUiIntent, ForumPartialChange, ForumUiState, ForumUiEvent>() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.forum.threadlist
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.AgreeBean
|
||||
import com.huanchengfly.tieba.post.api.models.protos.ThreadInfo
|
||||
|
|
@ -56,12 +57,14 @@ enum class ForumThreadListType {
|
|||
Latest, Good
|
||||
}
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class LatestThreadListViewModel @Inject constructor() : ForumThreadListViewModel() {
|
||||
override fun createPartialChangeProducer(): PartialChangeProducer<ForumThreadListUiIntent, ForumThreadListPartialChange, ForumThreadListUiState> =
|
||||
ForumThreadListPartialChangeProducer(ForumThreadListType.Latest)
|
||||
}
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class GoodThreadListViewModel @Inject constructor() : ForumThreadListViewModel() {
|
||||
override fun createPartialChangeProducer(): PartialChangeProducer<ForumThreadListUiIntent, ForumThreadListPartialChange, ForumThreadListUiState> =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.history.list
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorMessage
|
||||
import com.huanchengfly.tieba.post.arch.BaseViewModel
|
||||
import com.huanchengfly.tieba.post.arch.PartialChange
|
||||
|
|
@ -43,12 +44,14 @@ abstract class HistoryListViewModel :
|
|||
}
|
||||
}
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class ThreadHistoryListViewModel @Inject constructor() : HistoryListViewModel() {
|
||||
override fun createPartialChangeProducer(): PartialChangeProducer<HistoryListUiIntent, HistoryListPartialChange, HistoryListUiState> =
|
||||
HistoryListPartialChangeProducer(HistoryUtil.TYPE_THREAD)
|
||||
}
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class ForumHistoryListViewModel @Inject constructor() : HistoryListViewModel() {
|
||||
override fun createPartialChangeProducer(): PartialChangeProducer<HistoryListUiIntent, HistoryListPartialChange, HistoryListUiState> =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.hottopic.list
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.protos.topicList.NewTopicList
|
||||
import com.huanchengfly.tieba.post.api.models.protos.topicList.TopicListResponse
|
||||
|
|
@ -20,6 +21,7 @@ import kotlinx.coroutines.flow.merge
|
|||
import kotlinx.coroutines.flow.onStart
|
||||
import javax.inject.Inject
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class HotTopicListViewModel @Inject constructor() :
|
||||
BaseViewModel<HotTopicListUiIntent, HotTopicListPartialChange, HotTopicListUiState, UiEvent>() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.main
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.arch.BaseViewModel
|
||||
import com.huanchengfly.tieba.post.arch.PartialChange
|
||||
import com.huanchengfly.tieba.post.arch.PartialChangeProducer
|
||||
|
|
@ -13,6 +14,7 @@ import kotlinx.coroutines.flow.map
|
|||
import kotlinx.coroutines.flow.merge
|
||||
import javax.inject.Inject
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class MainViewModel @Inject constructor() : BaseViewModel<MainUiIntent, MainPartialChange, MainUiState, MainUiEvent>() {
|
||||
override fun createInitialState(): MainUiState = MainUiState()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.main.explore.concern
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.App
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.AgreeBean
|
||||
|
|
@ -26,6 +27,7 @@ import kotlinx.coroutines.flow.merge
|
|||
import kotlinx.coroutines.flow.onStart
|
||||
import javax.inject.Inject
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class ConcernViewModel @Inject constructor() :
|
||||
BaseViewModel<ConcernUiIntent, ConcernPartialChange, ConcernUiState, ConcernUiEvent>() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.main.explore.hot
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.protos.FrsTabInfo
|
||||
import com.huanchengfly.tieba.post.api.models.protos.RecommendTopicList
|
||||
|
|
@ -22,6 +23,7 @@ import kotlinx.coroutines.flow.merge
|
|||
import kotlinx.coroutines.flow.onStart
|
||||
import javax.inject.Inject
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class HotViewModel @Inject constructor() :
|
||||
BaseViewModel<HotUiIntent, HotPartialChange, HotUiState, HotUiEvent>() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.main.explore.personalized
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.AgreeBean
|
||||
import com.huanchengfly.tieba.post.api.models.CommonResponse
|
||||
|
|
@ -29,6 +30,7 @@ import kotlinx.coroutines.flow.merge
|
|||
import kotlinx.coroutines.flow.onStart
|
||||
import javax.inject.Inject
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class PersonalizedViewModel @Inject constructor() :
|
||||
BaseViewModel<PersonalizedUiIntent, PersonalizedPartialChange, PersonalizedUiState, PersonalizedUiEvent>() {
|
||||
|
|
@ -44,6 +46,7 @@ class PersonalizedViewModel @Inject constructor() :
|
|||
is PersonalizedPartialChange.Refresh.Success -> PersonalizedUiEvent.RefreshSuccess(
|
||||
partialChange.data.size
|
||||
)
|
||||
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.main.notifications.list
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.MessageListBean
|
||||
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorMessage
|
||||
|
|
@ -22,6 +23,7 @@ abstract class NotificationsListViewModel :
|
|||
}
|
||||
}
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class ReplyMeListViewModel @Inject constructor() : NotificationsListViewModel() {
|
||||
override fun createPartialChangeProducer():
|
||||
|
|
@ -30,6 +32,7 @@ class ReplyMeListViewModel @Inject constructor() : NotificationsListViewModel()
|
|||
}
|
||||
}
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class AtMeListViewModel @Inject constructor() : NotificationsListViewModel() {
|
||||
override fun createPartialChangeProducer():
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.main.user
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.Profile
|
||||
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorMessage
|
||||
|
|
@ -11,6 +12,7 @@ import kotlinx.coroutines.FlowPreview
|
|||
import kotlinx.coroutines.flow.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class UserViewModel @Inject constructor() : BaseViewModel<UserUiIntent, UserPartialChange, UserUiState, UserUiEvent>() {
|
||||
override fun createInitialState(): UserUiState =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.threadstore
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.CommonResponse
|
||||
import com.huanchengfly.tieba.post.api.models.ThreadStoreBean
|
||||
|
|
@ -24,6 +25,7 @@ import kotlinx.coroutines.flow.merge
|
|||
import kotlinx.coroutines.flow.onStart
|
||||
import javax.inject.Inject
|
||||
|
||||
@Stable
|
||||
@HiltViewModel
|
||||
class ThreadStoreViewModel @Inject constructor() :
|
||||
BaseViewModel<ThreadStoreUiIntent, ThreadStorePartialChange, ThreadStoreUiState, ThreadStoreUiEvent>() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue