Skip to content

Commit

Permalink
Prevent crash when subscriber is invoked after view is destroyed.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-signal committed Jul 11, 2022
1 parent 78d4d9a commit c906abd
Showing 1 changed file with 7 additions and 0 deletions.
Expand Up @@ -31,6 +31,7 @@ import com.google.android.material.button.MaterialButton
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Observable
import org.signal.core.util.DimensionUnit
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.components.AvatarImageView
import org.thoughtcrime.securesms.components.segmentedprogressbar.SegmentedProgressBar
Expand Down Expand Up @@ -334,6 +335,10 @@ class StoryViewerPageFragment :
return@subscribe
}

if (context == null) {
Log.d(TAG, "Subscriber called while fragment is detached. Ignoring state update.")
}

if (state.posts.isNotEmpty() && state.selectedPostIndex in state.posts.indices) {
val post = state.posts[state.selectedPostIndex]

Expand Down Expand Up @@ -936,6 +941,8 @@ class StoryViewerPageFragment :
}

companion object {
private val TAG = Log.tag(StoryViewerPageFragment::class.java)

private val MAX_VIDEO_PLAYBACK_DURATION: Long = TimeUnit.SECONDS.toMillis(30)
private val MIN_GIF_LOOPS: Long = 3L
private val MIN_GIF_PLAYBACK_DURATION = TimeUnit.SECONDS.toMillis(5)
Expand Down

0 comments on commit c906abd

Please sign in to comment.