diff --git a/apps/files/src/services/Files.ts b/apps/files/src/services/Files.ts index 86d9f9b8e80..944c2d30678 100644 --- a/apps/files/src/services/Files.ts +++ b/apps/files/src/services/Files.ts @@ -2,11 +2,11 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import type { ContentsWithRoot } from '@nextcloud/files' +import type { ContentsWithRoot, File, Folder } from '@nextcloud/files' import type { FileStat, ResponseDataDetailed } from 'webdav' import { CancelablePromise } from 'cancelable-promise' -import { File, Folder, davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files' +import { davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files' import { client } from './WebdavClient.ts' import logger from '../logger.ts' @@ -14,14 +14,7 @@ import logger from '../logger.ts' * Slim wrapper over `@nextcloud/files` `davResultToNode` to allow using the function with `Array.map` * @param node The node returned by the webdav library */ -export const resultToNode = (node: FileStat): File | Folder => { - // TODO remove this hack with nextcloud-files v3.7 - // just needed because of a bug in the webdav client - if (node.props?.displayname !== undefined) { - node.props.displayname = String(node.props.displayname) - } - return davResultToNode(node) -} +export const resultToNode = (node: FileStat): File | Folder => davResultToNode(node) export const getContents = (path = '/'): CancelablePromise => { const controller = new AbortController() diff --git a/apps/files/src/services/Recent.ts b/apps/files/src/services/Recent.ts index c8cde136069..0a953087781 100644 --- a/apps/files/src/services/Recent.ts +++ b/apps/files/src/services/Recent.ts @@ -3,18 +3,26 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ import type { ContentsWithRoot, Node } from '@nextcloud/files' -import type { ResponseDataDetailed, SearchResult } from 'webdav' +import type { FileStat, ResponseDataDetailed, SearchResult } from 'webdav' import { getCurrentUser } from '@nextcloud/auth' -import { Folder, Permission, davGetRecentSearch, davRootPath, davRemoteURL } from '@nextcloud/files' +import { Folder, Permission, davGetRecentSearch, davRootPath, davRemoteURL, davResultToNode } from '@nextcloud/files' import { CancelablePromise } from 'cancelable-promise' import { useUserConfigStore } from '../store/userconfig.ts' import { pinia } from '../store/index.ts' import { client } from './WebdavClient.ts' -import { resultToNode } from './Files.ts' +import { getBaseUrl } from '@nextcloud/router' const lastTwoWeeksTimestamp = Math.round((Date.now() / 1000) - (60 * 60 * 24 * 14)) +/** + * Helper to map a WebDAV result to a Nextcloud node + * The search endpoint already includes the dav remote URL so we must not include it in the source + * + * @param stat the WebDAV result + */ +const resultToNode = (stat: FileStat) => davResultToNode(stat, davRootPath, getBaseUrl()) + /** * Get recently changed nodes *