prevent thread view from scrolling when post is interacted with (#3164)
* prevent thread view from scrolling when post is interacted with * fix ktlint
This commit is contained in:
parent
98eb324aa0
commit
9abf1e5e33
|
@ -202,11 +202,21 @@ class ViewThreadFragment : SFragment(), OnRefreshListener, StatusActionListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is ThreadUiState.Success -> {
|
is ThreadUiState.Success -> {
|
||||||
|
if (uiState.statusViewData.none { viewData -> viewData.isDetailed }) {
|
||||||
|
// no detailed statuses available, e.g. because author is blocked
|
||||||
|
activity?.finish()
|
||||||
|
return@collect
|
||||||
|
}
|
||||||
|
|
||||||
threadProgressBar.cancel()
|
threadProgressBar.cancel()
|
||||||
|
|
||||||
adapter.submitList(uiState.statusViewData) {
|
adapter.submitList(uiState.statusViewData) {
|
||||||
// Ensure the top of the status is visible
|
if (viewModel.isInitialLoad) {
|
||||||
(binding.recyclerView.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(uiState.detailedStatusPosition, 0)
|
viewModel.isInitialLoad = false
|
||||||
|
|
||||||
|
// Ensure the top of the status is visible
|
||||||
|
(binding.recyclerView.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(uiState.detailedStatusPosition, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRevealButton(uiState.revealButton)
|
updateRevealButton(uiState.revealButton)
|
||||||
|
|
|
@ -70,6 +70,8 @@ class ViewThreadViewModel @Inject constructor(
|
||||||
val errors: Flow<Throwable>
|
val errors: Flow<Throwable>
|
||||||
get() = _errors
|
get() = _errors
|
||||||
|
|
||||||
|
var isInitialLoad: Boolean = true
|
||||||
|
|
||||||
private val alwaysShowSensitiveMedia: Boolean
|
private val alwaysShowSensitiveMedia: Boolean
|
||||||
private val alwaysOpenSpoiler: Boolean
|
private val alwaysOpenSpoiler: Boolean
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue