aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-06-10 23:06:02 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-06-11 15:45:22 +0200
commit53324821be9af80f9269454dfcbd4066369f1ea4 (patch)
tree58d1697817242d0672d1154261ecfd02671417f4 /apps/files
parentde2276e6d7e1f499012502c40718a217b594475b (diff)
downloadnextcloud-server-53324821be9af80f9269454dfcbd4066369f1ea4.tar.gz
nextcloud-server-53324821be9af80f9269454dfcbd4066369f1ea4.zip
refactor(files): Migrate `personal` view to `@nextcloud/files` functions
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/src/services/PersonalFiles.ts45
1 files changed, 22 insertions, 23 deletions
diff --git a/apps/files/src/services/PersonalFiles.ts b/apps/files/src/services/PersonalFiles.ts
index 3d6ef7c7430..6d86bd3bae2 100644
--- a/apps/files/src/services/PersonalFiles.ts
+++ b/apps/files/src/services/PersonalFiles.ts
@@ -2,39 +2,38 @@
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-import { File, type ContentsWithRoot } from '@nextcloud/files'
-import { getCurrentUser } from '@nextcloud/auth';
+import type { Node, ContentsWithRoot } from '@nextcloud/files'
+import type { CancelablePromise } from 'cancelable-promise'
+import { getCurrentUser } from '@nextcloud/auth'
-import { getContents as getFiles } from './Files';
+import { getContents as getFiles } from './Files'
-const currUserID = getCurrentUser()?.uid
+const currentUserId = getCurrentUser()?.uid
/**
- * NOTE MOVE TO @nextcloud/files
- * @brief filters each file/folder on its shared status
- * A personal file is considered a file that has all of the following properties:
- * a.) the current user owns
- * b.) the file is not shared with anyone
- * c.) the file is not a group folder
- * @param {FileStat} node that contains
- * @return {Boolean}
+ * Filters each file/folder on its shared status
+ *
+ * A personal file is considered a file that has all of the following properties:
+ * 1. the current user owns
+ * 2. the file is not shared with anyone
+ * 3. the file is not a group folder
+ * @todo Move to `@nextcloud/files`
+ * @param node The node to check
*/
-export const isPersonalFile = function(node: File): Boolean {
+export const isPersonalFile = function(node: Node): boolean {
// the type of mounts that determine whether the file is shared
- const sharedMountTypes = ["group", "shared"]
+ const sharedMountTypes = ['group', 'shared']
const mountType = node.attributes['mount-type']
- // the check to determine whether the current logged in user is the owner / creator of the node
- const currUserCreated = currUserID ? node.owner === currUserID : true
- return currUserCreated && !sharedMountTypes.includes(mountType)
+ return currentUserId === node.owner && !sharedMountTypes.includes(mountType)
}
-export const getContents = (path: string = "/"): Promise<ContentsWithRoot> => {
+export const getContents = (path: string = '/'): CancelablePromise<ContentsWithRoot> => {
// get all the files from the current path as a cancellable promise
// then filter the files that the user does not own, or has shared / is a group folder
- return getFiles(path)
- .then(c => {
- c.contents = c.contents.filter(isPersonalFile) as File[]
- return c
+ return getFiles(path)
+ .then((content) => {
+ content.contents = content.contents.filter(isPersonalFile)
+ return content
})
-} \ No newline at end of file
+}