mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-10 05:20:38 +01:00
fix: retaining custom sort type after navigation (#424)
This commit is contained in:
parent
4e966da936
commit
4c7f4282c7
@ -87,7 +87,6 @@ class CommunityDetailViewModel(
|
|||||||
blurNsfw = settings.blurNsfw,
|
blurNsfw = settings.blurNsfw,
|
||||||
swipeActionsEnabled = settings.enableSwipeActions,
|
swipeActionsEnabled = settings.enableSwipeActions,
|
||||||
doubleTapActionEnabled = settings.enableDoubleTapAction,
|
doubleTapActionEnabled = settings.enableDoubleTapAction,
|
||||||
sortType = settings.defaultPostSortType.toSortType(),
|
|
||||||
fullHeightImages = settings.fullHeightImages,
|
fullHeightImages = settings.fullHeightImages,
|
||||||
voteFormat = settings.voteFormat,
|
voteFormat = settings.voteFormat,
|
||||||
autoLoadImages = settings.autoLoadImages,
|
autoLoadImages = settings.autoLoadImages,
|
||||||
@ -148,6 +147,9 @@ class CommunityDetailViewModel(
|
|||||||
mvi.updateState { it.copy(currentUserId = user?.id ?: 0) }
|
mvi.updateState { it.copy(currentUserId = user?.id ?: 0) }
|
||||||
}
|
}
|
||||||
if (mvi.uiState.value.posts.isEmpty()) {
|
if (mvi.uiState.value.posts.isEmpty()) {
|
||||||
|
val defaultPostSortType =
|
||||||
|
settingsRepository.currentSettings.value.defaultPostSortType
|
||||||
|
mvi.updateState { it.copy(sortType = defaultPostSortType.toSortType()) }
|
||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,6 @@ class PostDetailViewModel(
|
|||||||
it.copy(
|
it.copy(
|
||||||
swipeActionsEnabled = settings.enableSwipeActions,
|
swipeActionsEnabled = settings.enableSwipeActions,
|
||||||
doubleTapActionEnabled = settings.enableDoubleTapAction,
|
doubleTapActionEnabled = settings.enableDoubleTapAction,
|
||||||
sortType = settings.defaultCommentSortType.toSortType(),
|
|
||||||
voteFormat = settings.voteFormat,
|
voteFormat = settings.voteFormat,
|
||||||
autoLoadImages = settings.autoLoadImages,
|
autoLoadImages = settings.autoLoadImages,
|
||||||
fullHeightImages = settings.fullHeightImages,
|
fullHeightImages = settings.fullHeightImages,
|
||||||
@ -183,7 +182,14 @@ class PostDetailViewModel(
|
|||||||
if (mvi.uiState.value.comments.isEmpty()) {
|
if (mvi.uiState.value.comments.isEmpty()) {
|
||||||
val sortTypes =
|
val sortTypes =
|
||||||
getSortTypesUseCase.getTypesForComments(otherInstance = otherInstance)
|
getSortTypesUseCase.getTypesForComments(otherInstance = otherInstance)
|
||||||
mvi.updateState { it.copy(availableSortTypes = sortTypes) }
|
val defaultCommentSortType =
|
||||||
|
settingsRepository.currentSettings.value.defaultCommentSortType.toSortType()
|
||||||
|
mvi.updateState {
|
||||||
|
it.copy(
|
||||||
|
sortType = defaultCommentSortType,
|
||||||
|
availableSortTypes = sortTypes,
|
||||||
|
)
|
||||||
|
}
|
||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,6 @@ class UserDetailViewModel(
|
|||||||
blurNsfw = settings.blurNsfw,
|
blurNsfw = settings.blurNsfw,
|
||||||
swipeActionsEnabled = settings.enableSwipeActions,
|
swipeActionsEnabled = settings.enableSwipeActions,
|
||||||
doubleTapActionEnabled = settings.enableDoubleTapAction,
|
doubleTapActionEnabled = settings.enableDoubleTapAction,
|
||||||
sortType = settings.defaultPostSortType.toSortType(),
|
|
||||||
voteFormat = settings.voteFormat,
|
voteFormat = settings.voteFormat,
|
||||||
autoLoadImages = settings.autoLoadImages,
|
autoLoadImages = settings.autoLoadImages,
|
||||||
fullHeightImages = settings.fullHeightImages,
|
fullHeightImages = settings.fullHeightImages,
|
||||||
@ -115,6 +114,10 @@ class UserDetailViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.posts.isEmpty()) {
|
if (uiState.value.posts.isEmpty()) {
|
||||||
|
val defaultPostSortType =
|
||||||
|
settingsRepository.currentSettings.value.defaultPostSortType
|
||||||
|
mvi.updateState { it.copy(sortType = defaultPostSortType.toSortType()) }
|
||||||
|
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
refresh(initial = true)
|
refresh(initial = true)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user