diff options
author | Eduardo Morales <emoral435@gmail.com> | 2024-02-02 10:34:49 -0600 |
---|---|---|
committer | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-02-15 09:03:11 +0100 |
commit | 8df8522cce87129debb26f49c5e02cf2738bd666 (patch) | |
tree | f5d05f568a8883e98913884975653fe7b40a814a /apps/files | |
parent | de954148befb64d0b39919788139a30276281936 (diff) | |
download | nextcloud-server-8df8522cce87129debb26f49c5e02cf2738bd666.tar.gz nextcloud-server-8df8522cce87129debb26f49c5e02cf2738bd666.zip |
feat: changed filtering logic
Signed-off-by: Eduardo Morales <emoral435@gmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/src/services/PersonalFiles.ts | 28 | ||||
-rw-r--r-- | apps/files/src/views/personal-files.ts | 24 |
2 files changed, 15 insertions, 37 deletions
diff --git a/apps/files/src/services/PersonalFiles.ts b/apps/files/src/services/PersonalFiles.ts index 39f9ab90e28..c74632a77ff 100644 --- a/apps/files/src/services/PersonalFiles.ts +++ b/apps/files/src/services/PersonalFiles.ts @@ -32,26 +32,26 @@ import { getClient } from './WebdavClient'; const client = getClient() /** + * NOTE MOVE TO @nextcloud/files * @brief filters each file/folder on its shared statuses - * MOVE TO @nextcloud/files - * - * eventually, this should be the WebDAV search, similar to - * * @param {FileStat} node that contains * @return {Boolean} */ -export const davNotShared = function(node: FileStat): Boolean { - // could use further filtering based on this issues description - // https://github.com/nextcloud/server/issues/42919 - return node.props?.['owner-id'] === getCurrentUser()?.uid.toString() - && node.props?.['share-types'] === "" +export const davNotShared = function(node: File | Folder | null, currUserID: string | undefined): Boolean { + // (essentially .filter(Boolean)) + if (!node) return false + + const isNotShared = currUserID ? node.attributes['owner-id'] === currUserID : true + && node.attributes['mount-type'] !== 'group' + && node.attributes['mount-type'] !== 'shared' + + return isNotShared } export const getContents = (path: string = "/"): Promise<ContentsWithRoot> => { const controller = new AbortController() - // FIXME we would filter each file during the WebDAV query, instead of after getting all the files - // and then filtering from there - const propfindPayload = davGetDefaultPropfind() // change the davGet here + const propfindPayload = davGetDefaultPropfind() + const currUserID = getCurrentUser()?.uid.toString() return new CancelablePromise(async (resolve, reject, onCancel) => { onCancel(() => controller.abort()) @@ -72,14 +72,14 @@ export const getContents = (path: string = "/"): Promise<ContentsWithRoot> => { resolve({ folder: resultToNode(root) as Folder, - contents: contents.filter(davNotShared).map(result => { + contents: contents.map(result => { try { return resultToNode(result) } catch (error) { logger.error(`Invalid node detected '${result.basename}'`, { error }) return null } - }).filter(Boolean) as File[], + }).filter(node => davNotShared(node, currUserID)) as File[], }) } catch (error) { reject(error) diff --git a/apps/files/src/views/personal-files.ts b/apps/files/src/views/personal-files.ts index 5ed3ab82439..066466c4934 100644 --- a/apps/files/src/views/personal-files.ts +++ b/apps/files/src/views/personal-files.ts @@ -26,12 +26,6 @@ import { getContents } from '../services/PersonalFiles' import FolderHome from '@mdi/svg/svg/folder-home.svg?raw' import logger from '../logger' -/** - * NOTE since we are only filtering at the root level, we only need to use the - * getContents methods only on this default folder view / route / path. - * Every other subroot from the main root with be rendered normally, as it - * would be in the all-files paths. -*/ export default () => { logger.debug("Loading root level personal files view...") @@ -41,7 +35,7 @@ export default () => { name: t('files', 'Personal Files'), caption: t('files', 'List of your files and folders that are not shared.'), - emptyTitle: t('files', 'No personal files found.'), + emptyTitle: t('files', 'No personal files found'), emptyCaption: t('files', 'Files that are not shared will show up here.'), icon: FolderHome, @@ -49,20 +43,4 @@ export default () => { getContents, })) - - /** - * Update personal files view when a folder is no longer shared - */ - // subscribe() - - /** - * Update personal files view when a folder is shared from the user - */ - // subscribe() - - /** - * Sort the personal files paths array and - * update the order property of the existing views - */ - // const updateAndSortViews = () => {} } |