From 0535a95efbf5e23bf9fcb1226779dd07004890fa Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 31 Jul 2024 16:52:24 +0200 Subject: fix(systemtags): Correctly set the display name for the Nextcloud node Signed-off-by: Ferdinand Thiessen Signed-off-by: nextcloud-command Signed-off-by: nextcloud-command --- apps/systemtags/src/services/systemtags.ts | 33 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'apps') diff --git a/apps/systemtags/src/services/systemtags.ts b/apps/systemtags/src/services/systemtags.ts index 4e81ec7dce0..27a8b1c6874 100644 --- a/apps/systemtags/src/services/systemtags.ts +++ b/apps/systemtags/src/services/systemtags.ts @@ -19,33 +19,36 @@ * along with this program. If not, see . * */ +import type { ContentsWithRoot } from '@nextcloud/files' import type { FileStat, ResponseDataDetailed } from 'webdav' import type { TagWithId } from '../types' -import { Folder, type ContentsWithRoot, Permission, getDavNameSpaces, getDavProperties } from '@nextcloud/files' -import { generateRemoteUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' - +import { Folder, Permission, getDavNameSpaces, getDavProperties, davGetClient, davResultToNode, davRemoteURL, davRootPath } from '@nextcloud/files' import { fetchTags } from './api' -import { getClient } from '../../../files/src/services/WebdavClient' -import { resultToNode } from '../../../files/src/services/Files' + +const rootPath = '/systemtags' + +const client = davGetClient() +const resultToNode = (node: FileStat) => davResultToNode(node) const formatReportPayload = (tagId: number) => ` ${getDavProperties()} - - ${tagId} - + + ${tagId} + ` const tagToNode = function(tag: TagWithId): Folder { return new Folder({ id: tag.id, - source: generateRemoteUrl('dav/systemtags/' + tag.id), - owner: getCurrentUser()?.uid as string, - root: '/systemtags', + source: `${davRemoteURL}${rootPath}/${tag.id}`, + owner: String(getCurrentUser()?.uid ?? 'anonymous'), + root: rootPath, + displayname: tag.displayName, permissions: Permission.READ, attributes: { ...tag, @@ -62,16 +65,16 @@ export const getContents = async (path = '/'): Promise => { return { folder: new Folder({ id: 0, - source: generateRemoteUrl('dav/systemtags'), + source: `${davRemoteURL}${rootPath}`, owner: getCurrentUser()?.uid as string, - root: '/systemtags', + root: rootPath, permissions: Permission.NONE, }), contents: tagsCache.map(tagToNode), } } - const tagId = parseInt(path.replace('/', ''), 10) + const tagId = parseInt(path.split('/', 2)[0]) const tag = tagsCache.find(tag => tag.id === tagId) if (!tag) { @@ -79,7 +82,7 @@ export const getContents = async (path = '/'): Promise => { } const folder = tagToNode(tag) - const contentsResponse = await getClient().getDirectoryContents('/', { + const contentsResponse = await client.getDirectoryContents(davRootPath, { details: true, // Only filter favorites if we're at the root data: formatReportPayload(tagId), -- cgit v1.2.3