Merge pull request #1089 from vector-im/feature/crash_in_attachment_preview

Fix crash on attachment preview screen (#1088)
This commit is contained in:
Benoit Marty 2020-02-28 14:49:36 +01:00 committed by GitHub
commit 41b4f412c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)
}