From 339ef62514493f50267610d44cba63b683d6f297 Mon Sep 17 00:00:00 2001 From: joragua Date: Wed, 2 Oct 2024 14:16:08 +0200 Subject: [PATCH] refactor: some changes in prepareOptionsMenu structure in text preview --- .../owncloud/android/ui/preview/PreviewTextFragment.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.kt index 71937bf6003..7be4610d580 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.kt @@ -227,15 +227,12 @@ class PreviewTextFragment : FileFragment() { override fun onPrepareOptionsMenu(menu: Menu) { mContainerActivity.storageManager?.let { + val safeFile = file val accountName = it.account.name - collectLatestLifecycleFlow(previewTextViewModel.getCurrentFile()) { currentFile -> - if (currentFile != null) { - previewTextViewModel.filterMenuOptions(currentFile, accountName) - } - } + previewTextViewModel.filterMenuOptions(safeFile,accountName) collectLatestLifecycleFlow(previewTextViewModel.menuOptions) { menuOptions -> - val hasWritePermission = file.hasWritePermission + val hasWritePermission = safeFile.hasWritePermission menu.filterMenuOptions(menuOptions, hasWritePermission) } }