Fix freeze of first story first post.

This commit is contained in:
Alex Hart
2022-05-12 13:31:13 -03:00
committed by Cody Henthorne
parent bcfe2fef72
commit e51841a28b
4 changed files with 50 additions and 2 deletions

View File

@@ -257,6 +257,7 @@ class StoryViewerPageFragment :
progressBar.setPosition(viewModel.getRestartIndex())
videoControlsDelegate.restart()
}
viewModel.setIsFirstPage(parentState.page == 0)
viewModel.setIsSelectedPage(true)
when (parentState.crossfadeSource) {
is StoryViewerState.CrossfadeSource.TextModel -> storyCrossfader.setSourceView(parentState.crossfadeSource.storyTextPostModel)

View File

@@ -3,7 +3,8 @@ package org.thoughtcrime.securesms.stories.viewer.page
data class StoryViewerPageState(
val posts: List<StoryPost> = emptyList(),
val selectedPostIndex: Int = 0,
val replyState: ReplyState = ReplyState.NONE
val replyState: ReplyState = ReplyState.NONE,
val isFirstPage: Boolean = false
) {
/**
* Indicates which Reply method is available when the user swipes on the dialog

View File

@@ -116,7 +116,9 @@ class StoryViewerPageViewModel(
}
val postIndex = store.state.selectedPostIndex
setSelectedPostIndex(max(-1, postIndex - 1))
val minIndex = if (store.state.isFirstPage) 0 else -1
setSelectedPostIndex(max(minIndex, postIndex - 1))
}
fun getRestartIndex(): Int {
@@ -155,6 +157,10 @@ class StoryViewerPageViewModel(
storyViewerPlaybackStore.update { it.copy(isDisplayingSlate = isDisplayingSlate) }
}
fun setIsFirstPage(isFirstPage: Boolean) {
store.update { it.copy(isFirstPage = isFirstPage) }
}
fun setIsSelectedPage(isSelectedPage: Boolean) {
storyViewerPlaybackStore.update { it.copy(isSelectedPage = isSelectedPage) }
}