Skip to content

Commit e10a2b1

Browse files
committed
refactor(files): migrate to @nextcloud/sharing
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
1 parent 5bb1211 commit e10a2b1

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

apps/files/src/components/TemplatePreview.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848

4949
<script>
5050
import { generateUrl } from '@nextcloud/router'
51+
import { isPublicShare, getSharingToken } from '@nextcloud/sharing/public'
5152
import { encodeFilePath } from '../utils/fileUtils.ts'
52-
import { getToken, isPublic } from '../utils/davUtils.js'
5353
5454
// preview width generation
5555
const previewWidth = 256
@@ -123,8 +123,8 @@ export default {
123123
return this.previewUrl
124124
}
125125
// TODO: find a nicer standard way of doing this?
126-
if (isPublic()) {
127-
return generateUrl(`/apps/files_sharing/publicpreview/${getToken()}?fileId=${this.fileid}&file=${encodeFilePath(this.filename)}&x=${previewWidth}&y=${previewWidth}&a=1`)
126+
if (isPublicShare()) {
127+
return generateUrl(`/apps/files_sharing/publicpreview/${getSharingToken()}?fileId=${this.fileid}&file=${encodeFilePath(this.filename)}&x=${previewWidth}&y=${previewWidth}&a=1`)
128128
}
129129
return generateUrl(`/core/preview?fileId=${this.fileid}&x=${previewWidth}&y=${previewWidth}&a=1`)
130130
},

apps/files/src/utils/davUtils.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,9 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import { getCurrentUser } from '@nextcloud/auth'
76
import { t } from '@nextcloud/l10n'
87
import type { WebDAVClientError } from 'webdav'
98

10-
/**
11-
* Check whether this is a public share
12-
* @return {boolean} Whether this is a public share
13-
*/
14-
export function isPublic() {
15-
return !getCurrentUser()
16-
}
17-
18-
/**
19-
* Get the sharing token
20-
* @return {string|null} The sharing token
21-
*/
22-
export function getToken() {
23-
const tokenElement = document.getElementById('sharingToken') as (HTMLInputElement | null)
24-
return tokenElement?.value
25-
}
26-
279
/**
2810
* Whether error is a WebDAVClientError
2911
* @param error - Any exception

0 commit comments

Comments
 (0)