mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
feat: changed filtering logic
Signed-off-by: Eduardo Morales <emoral435@gmail.com>
This commit is contained in:
parent
de954148be
commit
8df8522cce
2 changed files with 15 additions and 37 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 = () => {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue