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
2 changed files with 14 additions and 2 deletions
|
@ -202,12 +202,22 @@ class ViewThreadFragment : SFragment(), OnRefreshListener, StatusActionListener,
|
|||
}
|
||||
}
|
||||
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()
|
||||
|
||||
adapter.submitList(uiState.statusViewData) {
|
||||
if (viewModel.isInitialLoad) {
|
||||
viewModel.isInitialLoad = false
|
||||
|
||||
// Ensure the top of the status is visible
|
||||
(binding.recyclerView.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(uiState.detailedStatusPosition, 0)
|
||||
}
|
||||
}
|
||||
|
||||
updateRevealButton(uiState.revealButton)
|
||||
binding.swipeRefreshLayout.isRefreshing = false
|
||||
|
|
|
@ -70,6 +70,8 @@ class ViewThreadViewModel @Inject constructor(
|
|||
val errors: Flow<Throwable>
|
||||
get() = _errors
|
||||
|
||||
var isInitialLoad: Boolean = true
|
||||
|
||||
private val alwaysShowSensitiveMedia: Boolean
|
||||
private val alwaysOpenSpoiler: Boolean
|
||||
|
||||
|
|
Loading…
Reference in a new issue