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:
Konrad Pozniak 2023-01-12 19:41:07 +01:00 committed by GitHub
parent 98eb324aa0
commit 9abf1e5e33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -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

View file

@ -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