Fix crash on attachment preview screen (#1088)

This commit is contained in:
Benoit Marty 2020-02-28 11:38:30 +01:00
parent 9bb4c7ed25
commit 151fec5ce0
2 changed files with 3 additions and 2 deletions

View file

@ -8,7 +8,7 @@ Improvements 🙌:
-
Bugfix 🐛:
-
- Fix crash on attachment preview screen (#1088)
Translations 🗣:
-

View file

@ -39,6 +39,7 @@ import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import com.yalantis.ucrop.UCrop
import com.yalantis.ucrop.UCropActivity
import im.vector.matrix.android.api.extensions.orFalse
import im.vector.matrix.android.api.session.content.ContentAttachmentData
import im.vector.riotx.R
import im.vector.riotx.core.extensions.cleanup
@ -115,7 +116,7 @@ class AttachmentsPreviewFragment @Inject constructor(
override fun onPrepareOptionsMenu(menu: Menu) {
withState(viewModel) { state ->
val editMenuItem = menu.findItem(R.id.attachmentsPreviewEditAction)
val showEditMenuItem = state.attachments[state.currentAttachmentIndex].isEditable()
val showEditMenuItem = state.attachments.getOrNull(state.currentAttachmentIndex)?.isEditable().orFalse()
editMenuItem.setVisible(showEditMenuItem)
}