@@ -6,12 +6,12 @@ import type { ContentsWithRoot } from '@nextcloud/files'
66import type { FileStat , ResponseDataDetailed } from 'webdav'
77import type { TagWithId } from '../types'
88
9- import { Folder , Permission , getDavNameSpaces , getDavProperties , davGetClient , davResultToNode } from '@nextcloud/files'
10- import { generateRemoteUrl } from '@nextcloud/router'
119import { getCurrentUser } from '@nextcloud/auth'
12-
10+ import { Folder , Permission , getDavNameSpaces , getDavProperties , davGetClient , davResultToNode , davRemoteURL , davRootPath } from '@nextcloud/files'
1311import { fetchTags } from './api'
1412
13+ const rootPath = '/systemtags'
14+
1515const client = davGetClient ( )
1616const resultToNode = ( node : FileStat ) => davResultToNode ( node )
1717
@@ -20,17 +20,18 @@ const formatReportPayload = (tagId: number) => `<?xml version="1.0"?>
2020 <d:prop>
2121 ${ getDavProperties ( ) }
2222 </d:prop>
23- <oc:filter-rules>
24- <oc:systemtag>${ tagId } </oc:systemtag>
25- </oc:filter-rules>
23+ <oc:filter-rules>
24+ <oc:systemtag>${ tagId } </oc:systemtag>
25+ </oc:filter-rules>
2626</oc:filter-files>`
2727
2828const tagToNode = function ( tag : TagWithId ) : Folder {
2929 return new Folder ( {
3030 id : tag . id ,
31- source : generateRemoteUrl ( 'dav/systemtags/' + tag . id ) ,
32- owner : getCurrentUser ( ) ?. uid as string ,
33- root : '/systemtags' ,
31+ source : `${ davRemoteURL } ${ rootPath } /${ tag . id } ` ,
32+ owner : String ( getCurrentUser ( ) ?. uid ?? 'anonymous' ) ,
33+ root : rootPath ,
34+ displayname : tag . displayName ,
3435 permissions : Permission . READ ,
3536 attributes : {
3637 ...tag ,
@@ -47,24 +48,24 @@ export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
4748 return {
4849 folder : new Folder ( {
4950 id : 0 ,
50- source : generateRemoteUrl ( 'dav/systemtags' ) ,
51+ source : ` ${ davRemoteURL } ${ rootPath } ` ,
5152 owner : getCurrentUser ( ) ?. uid as string ,
52- root : '/systemtags' ,
53+ root : rootPath ,
5354 permissions : Permission . NONE ,
5455 } ) ,
5556 contents : tagsCache . map ( tagToNode ) ,
5657 }
5758 }
5859
59- const tagId = parseInt ( path . replace ( '/' , '' ) , 10 )
60+ const tagId = parseInt ( path . split ( '/' , 2 ) [ 0 ] )
6061 const tag = tagsCache . find ( tag => tag . id === tagId )
6162
6263 if ( ! tag ) {
6364 throw new Error ( 'Tag not found' )
6465 }
6566
6667 const folder = tagToNode ( tag )
67- const contentsResponse = await client . getDirectoryContents ( '/' , {
68+ const contentsResponse = await client . getDirectoryContents ( davRootPath , {
6869 details : true ,
6970 // Only filter favorites if we're at the root
7071 data : formatReportPayload ( tagId ) ,
0 commit comments