mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 02:08:40 +00:00
Fix issue where StoryPostFragment tries to post updates after fragment is detached from Context.
This commit is contained in:
committed by
Cody Henthorne
parent
3738997832
commit
b762d95622
@@ -6,6 +6,7 @@ import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import org.signal.core.util.concurrent.LifecycleDisposable
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.ViewBinderDelegate
|
||||
import org.thoughtcrime.securesms.components.voice.VoiceNoteMediaControllerOwner
|
||||
@@ -22,6 +23,10 @@ import org.thoughtcrime.securesms.video.VideoPlayer.PlayerCallback
|
||||
*/
|
||||
class StoryPostFragment : Fragment(R.layout.stories_post_fragment) {
|
||||
|
||||
companion object {
|
||||
private val TAG = Log.tag(StoryPostFragment::class.java)
|
||||
}
|
||||
|
||||
private val postViewModel: StoryPostViewModel by viewModels(factoryProducer = {
|
||||
StoryPostViewModel.Factory(StoryTextPostRepository())
|
||||
})
|
||||
@@ -57,6 +62,11 @@ class StoryPostFragment : Fragment(R.layout.stories_post_fragment) {
|
||||
}
|
||||
|
||||
disposables += postViewModel.state.distinctUntilChanged().subscribe { state ->
|
||||
if (context == null) {
|
||||
Log.w(TAG, "Attempted state change while not attached to a context. Dropping.")
|
||||
return@subscribe
|
||||
}
|
||||
|
||||
when (state) {
|
||||
is StoryPostState.None -> presentNone()
|
||||
is StoryPostState.TextPost -> presentTextPost(state)
|
||||
|
||||
Reference in New Issue
Block a user