Skip to content

Commit 0e4438f

Browse files
authored
Merge pull request #47841 from nextcloud/fix/files-sharing-openfile
fix(files_sharing): Open single-file-share by default
2 parents 4e68e88 + 6ffe6e1 commit 0e4438f

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public function renderPage(IShare $share, string $token, string $path): Template
7777
$view = 'public-share';
7878
if ($shareNode instanceof File) {
7979
$view = 'public-file-share';
80+
$this->initialState->provideInitialState('fileId', $shareNode->getId());
8081
} elseif (($share->getPermissions() & \OCP\Constants::PERMISSION_CREATE)
8182
&& !($share->getPermissions() & \OCP\Constants::PERMISSION_READ)
8283
) {

apps/files_sharing/src/init-public.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,14 @@ navigation.setActive(navigation.views.find(({ id }) => id === view) ?? null)
2222
// Force our own router
2323
window.OCP.Files = window.OCP.Files ?? {}
2424
window.OCP.Files.Router = new RouterService(router)
25+
26+
// If this is a single file share, so set the fileid as active in the URL
27+
const fileId = loadState<number|null>('files_sharing', 'fileId', null)
28+
const token = loadState<string>('files_sharing', 'sharingToken')
29+
if (fileId !== null) {
30+
window.OCP.Files.Router.goToRoute(
31+
'filelist',
32+
{ ...window.OCP.Files.Router.params, token, fileid: String(fileId) },
33+
{ ...window.OCP.Files.Router.query, openfile: 'true' },
34+
)
35+
}

dist/files_sharing-init-public.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_sharing-init-public.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)