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