aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/files/lib/Controller/ViewController.php51
-rw-r--r--apps/files/src/components/FilesListVirtual.vue31
2 files changed, 20 insertions, 62 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 9722e2aadb0..06f79e30aca 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -277,61 +277,10 @@ class ViewController extends Controller {
$policy->addAllowedWorkerSrcDomain('\'self\'');
$response->setContentSecurityPolicy($policy);
- $this->provideInitialState($dir, $fileid);
-
return $response;
}
/**
- * Add openFileInfo in initialState.
- * @param string $dir - the ?dir= URL param
- * @param string $fileid - the fileid URL param
- * @return void
- */
- private function provideInitialState(string $dir, ?string $fileid): void {
- if ($fileid === null) {
- return;
- }
-
- $user = $this->userSession->getUser();
-
- if ($user === null) {
- return;
- }
-
- $uid = $user->getUID();
- $userFolder = $this->rootFolder->getUserFolder($uid);
- $node = $userFolder->getFirstNodeById((int) $fileid);
-
- if ($node === null) {
- return;
- }
-
- // properly format full path and make sure
- // we're relative to the user home folder
- $isRoot = $node === $userFolder;
- $path = $userFolder->getRelativePath($node->getPath());
- $directory = $userFolder->getRelativePath($node->getParent()->getPath());
-
- // Prevent opening a file from another folder.
- if ($dir !== $directory) {
- return;
- }
-
- $this->initialState->provideInitialState(
- 'fileInfo', [
- 'id' => $node->getId(),
- 'name' => $isRoot ? '' : $node->getName(),
- 'path' => $path,
- 'directory' => $directory,
- 'mime' => $node->getMimetype(),
- 'type' => $node->getType(),
- 'permissions' => $node->getPermissions(),
- ]
- );
- }
-
- /**
* Redirects to the trashbin file list and highlight the given file id
*
* @param int $fileId file id to show
diff --git a/apps/files/src/components/FilesListVirtual.vue b/apps/files/src/components/FilesListVirtual.vue
index 7ad703cd8f4..17a934ca5cf 100644
--- a/apps/files/src/components/FilesListVirtual.vue
+++ b/apps/files/src/components/FilesListVirtual.vue
@@ -76,7 +76,6 @@ import type { UserConfig } from '../types'
import { getFileListHeaders, Folder, View, getFileActions, FileType } from '@nextcloud/files'
import { showError } from '@nextcloud/dialogs'
-import { loadState } from '@nextcloud/initial-state'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import { defineComponent } from 'vue'
@@ -206,14 +205,23 @@ export default defineComponent({
},
watch: {
- fileId(fileId) {
- this.scrollToFile(fileId, false)
+ fileId: {
+ handler(fileId) {
+ this.scrollToFile(fileId, false)
+ },
+ immediate: true,
},
- openFile(open: boolean) {
- if (open) {
- this.$nextTick(() => this.handleOpenFile(this.fileId))
- }
+ openFile: {
+ handler() {
+ // wait for scrolling and updating the actions to settle
+ this.$nextTick(() => {
+ if (this.fileId && this.openFile) {
+ this.handleOpenFile(this.fileId)
+ }
+ })
+ },
+ immediate: true,
},
},
@@ -222,10 +230,11 @@ export default defineComponent({
const mainContent = window.document.querySelector('main.app-content') as HTMLElement
mainContent.addEventListener('dragover', this.onDragOver)
- const { id } = loadState<{ id?: number }>('files', 'fileInfo', {})
- this.scrollToFile(id ?? this.fileId)
- this.openSidebarForFile(id ?? this.fileId)
- this.handleOpenFile(id ?? null)
+ // If the file list is mounted with a fileId specified
+ // then we need to open the sidebar initially
+ if (this.fileId) {
+ this.openSidebarForFile(this.fileId)
+ }
},
beforeDestroy() {