Skip to content

Commit

Permalink
fix: disallow "top" sort type expansion for comments in post detail, …
Browse files Browse the repository at this point in the history
…user detail, explore (#272)

* fix: comment sort bottom sheet type in post detail

* chore: remove unused variable

* fix: comment sort bottom sheet type in user detail

* fix: comment sort bottom sheet type in explore
  • Loading branch information
AkesiSeli authored Jan 17, 2025
1 parent ecd09ff commit ac93d20
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
Expand Down Expand Up @@ -70,7 +69,6 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInParent
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.style.TextOverflow
Expand Down Expand Up @@ -198,10 +196,6 @@ class CommunityDetailScreen(
}
}
var itemIdToDelete by remember { mutableStateOf<Long?>(null) }
val statusBarInset =
with(LocalDensity.current) {
WindowInsets.statusBars.getTop(this)
}
var selectLanguageDialogOpen by remember { mutableStateOf(false) }
var unsubscribeConfirmDialogOpen by remember { mutableStateOf(false) }
var deleteConfirmDialogOpen by remember { mutableStateOf(false) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ class ExploreScreen(
if (sortBottomSheetOpened) {
SortBottomSheet(
values = uiState.availableSortTypes,
expandTop = true,
expandTop = uiState.resultType != SearchResultType.Comments,
onSelected = { value ->
sortBottomSheetOpened = false
if (value != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ class ExploreViewModel(
}

private suspend fun updateAvailableSortTypes() {
val sortTypes = getSortTypesUseCase.getTypesForPosts()
val sortTypes =
if (uiState.value.resultType == SearchResultType.Comments) {
getSortTypesUseCase.getTypesForComments(otherInstance = otherInstance)
} else {
getSortTypesUseCase.getTypesForPosts(otherInstance = otherInstance)
}
updateState { it.copy(availableSortTypes = sortTypes) }
}

Expand Down Expand Up @@ -362,6 +367,7 @@ class ExploreViewModel(
screenModelScope.launch {
updateState { it.copy(resultType = value) }
emitEffect(ExploreMviModel.Effect.BackToTop)
updateAvailableSortTypes()
refresh()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
Expand Down Expand Up @@ -206,10 +205,6 @@ class PostDetailScreen(
}
var postToDelete by remember { mutableStateOf<Unit?>(null) }
var commentIdToDelete by remember { mutableStateOf<Long?>(null) }
val statusBarInset =
with(LocalDensity.current) {
WindowInsets.statusBars.getTop(this)
}
val bottomNavigationInsetPx =
with(LocalDensity.current) {
WindowInsets.navigationBars.getBottom(this)
Expand Down Expand Up @@ -2006,7 +2001,7 @@ class PostDetailScreen(
if (sortBottomSheetOpened) {
SortBottomSheet(
values = uiState.availableSortTypes,
expandTop = true,
expandTop = false,
onSelected = { value ->
sortBottomSheetOpened = false
if (value != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ class UserDetailScreen(
if (sortBottomSheetOpened || defaultSortBottomSheetOpened) {
SortBottomSheet(
values = uiState.availableSortTypes,
expandTop = true,
expandTop = uiState.section == UserDetailSection.Posts,
onSelected = { value ->
val wasDefaultSortBottomSheetOpened = defaultSortBottomSheetOpened
sortBottomSheetOpened = false
Expand Down

0 comments on commit ac93d20

Please sign in to comment.