diff options
author | Grigorii K. Shartsev <me@shgk.me> | 2024-10-17 15:17:43 +0200 |
---|---|---|
committer | Grigorii K. Shartsev <me@shgk.me> | 2024-10-25 15:12:39 +0200 |
commit | 73d0a04241ef5ed16a9e2323a6aa6ab08c483af2 (patch) | |
tree | a2bf8341be93fa534b712d9d50e50e4fc0e08eb2 /apps | |
parent | 9563f19651bd648305ecc713fdfd90013f8f9066 (diff) | |
download | nextcloud-server-73d0a04241ef5ed16a9e2323a6aa6ab08c483af2.tar.gz nextcloud-server-73d0a04241ef5ed16a9e2323a6aa6ab08c483af2.zip |
refactor(files): migrate to @nextcloud/sharing
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/src/components/TemplatePreview.vue | 6 | ||||
-rw-r--r-- | apps/files/src/utils/davUtils.ts | 18 |
2 files changed, 3 insertions, 21 deletions
diff --git a/apps/files/src/components/TemplatePreview.vue b/apps/files/src/components/TemplatePreview.vue index 7737ebc030f..57af0bf9b64 100644 --- a/apps/files/src/components/TemplatePreview.vue +++ b/apps/files/src/components/TemplatePreview.vue @@ -33,7 +33,7 @@ <script> import { encodePath } from '@nextcloud/paths' import { generateUrl } from '@nextcloud/router' -import { getToken, isPublic } from '../utils/davUtils.ts' +import { isPublicShare, getSharingToken } from '@nextcloud/sharing/public' // preview width generation const previewWidth = 256 @@ -107,8 +107,8 @@ export default { return this.previewUrl } // TODO: find a nicer standard way of doing this? - if (isPublic()) { - return generateUrl(`/apps/files_sharing/publicpreview/${getToken()}?fileId=${this.fileid}&file=${encodePath(this.filename)}&x=${previewWidth}&y=${previewWidth}&a=1`) + if (isPublicShare()) { + return generateUrl(`/apps/files_sharing/publicpreview/${getSharingToken()}?fileId=${this.fileid}&file=${encodePath(this.filename)}&x=${previewWidth}&y=${previewWidth}&a=1`) } return generateUrl(`/core/preview?fileId=${this.fileid}&x=${previewWidth}&y=${previewWidth}&a=1`) }, diff --git a/apps/files/src/utils/davUtils.ts b/apps/files/src/utils/davUtils.ts index cf49df5b278..d8dc12d069d 100644 --- a/apps/files/src/utils/davUtils.ts +++ b/apps/files/src/utils/davUtils.ts @@ -3,28 +3,10 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -import { getCurrentUser } from '@nextcloud/auth' import { t } from '@nextcloud/l10n' import type { WebDAVClientError } from 'webdav' /** - * Check whether this is a public share - * @return {boolean} Whether this is a public share - */ -export function isPublic() { - return !getCurrentUser() -} - -/** - * Get the sharing token - * @return {string|null} The sharing token - */ -export function getToken() { - const tokenElement = document.getElementById('sharingToken') as (HTMLInputElement | null) - return tokenElement?.value -} - -/** * Whether error is a WebDAVClientError * @param error - Any exception * @return {boolean} - Whether error is a WebDAVClientError |