From c06723c44afbc16cf85d316fb086887c18de09c7 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 14 Nov 2024 23:24:47 +0100 Subject: [PATCH] refactor(files): Adjust `useNavigation` composable to enforce active view MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In some cases it is guaranteed that we have a proper active view, e.g. when the file list is loaded (so within FileEntry* components). This does not change anything but the Typescript types, so the `currentView` is typed as `View` instead of `View | null´. Signed-off-by: Ferdinand Thiessen --- apps/files/src/components/FileEntry.vue | 7 ++++--- .../components/FileEntry/FileEntryActions.vue | 10 +++++----- .../src/components/FileEntry/FileEntryName.vue | 9 +++++---- apps/files/src/components/FileEntryGrid.vue | 3 ++- .../src/composables/useNavigation.spec.ts | 18 +++++++++--------- apps/files/src/composables/useNavigation.ts | 9 ++++++--- 6 files changed, 31 insertions(+), 25 deletions(-) diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue index f6f93be1dc8..fc5c7fb97f6 100644 --- a/apps/files/src/components/FileEntry.vue +++ b/apps/files/src/components/FileEntry.vue @@ -74,7 +74,7 @@ @@ -135,7 +135,8 @@ export default defineComponent({ const filesStore = useFilesStore() const renamingStore = useRenamingStore() const selectionStore = useSelectionStore() - const { currentView } = useNavigation() + // The file list is guaranteed to be only shown with active view - thus we can set the `loaded` flag + const { currentView } = useNavigation(true) const { directory: currentDir, fileId: currentFileId, @@ -180,7 +181,7 @@ export default defineComponent({ if (this.filesListWidth < 512 || this.compact) { return [] } - return this.currentView?.columns || [] + return this.currentView.columns || [] }, size() { diff --git a/apps/files/src/components/FileEntry/FileEntryActions.vue b/apps/files/src/components/FileEntry/FileEntryActions.vue index 06b447295eb..8c150b78087 100644 --- a/apps/files/src/components/FileEntry/FileEntryActions.vue +++ b/apps/files/src/components/FileEntry/FileEntryActions.vue @@ -77,8 +77,8 @@