aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2024-08-13 11:25:47 -0700
committerChristopher Ng <chrng8@gmail.com>2024-08-22 16:09:10 -0700
commit3b185b1156e684ffbc84815d03b0bb29865b9c65 (patch)
tree8fb1243811e1ef11e9251ec3643f04d3c4b9fc1d /apps/files
parent4062883459397b52964f8560c02516d18b7733ca (diff)
downloadnextcloud-server-3b185b1156e684ffbc84815d03b0bb29865b9c65.tar.gz
nextcloud-server-3b185b1156e684ffbc84815d03b0bb29865b9c65.zip
refactor(files): Organize event subscriptions
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/src/views/folderTree.ts24
1 files changed, 10 insertions, 14 deletions
diff --git a/apps/files/src/views/folderTree.ts b/apps/files/src/views/folderTree.ts
index d74f982afc9..00b6da35aa6 100644
--- a/apps/files/src/views/folderTree.ts
+++ b/apps/files/src/views/folderTree.ts
@@ -36,7 +36,7 @@ const queue = new PQueue({ concurrency: 5, intervalCap: 5, interval: 200 })
const registerQueue = new PQueue({ concurrency: 5, intervalCap: 5, interval: 200 })
-const registerTreeNodes = async (path: string = '/') => {
+const registerTreeChildren = async (path: string = '/') => {
await queue.add(async () => {
const nodes = await getFolderTreeNodes(path)
const promises = nodes.map(node => registerQueue.add(() => registerTreeNodeView(node)))
@@ -52,7 +52,7 @@ const getLoadChildViews = (node: TreeNode | Folder) => {
}
// @ts-expect-error Custom property
view.loading = true
- await registerTreeNodes(node.path)
+ await registerTreeChildren(node.path)
// @ts-expect-error Custom property
view.loading = false
// @ts-expect-error Custom property
@@ -168,13 +168,13 @@ const onMoveNode = ({ node, oldSource }) => {
const onUserConfigUpdated = async ({ key, value }) => {
if (key === 'show_hidden') {
showHiddenFiles = value
- await registerTreeNodes()
+ await registerTreeChildren()
// @ts-expect-error No payload
emit('files:folder-tree:initialized')
}
}
-const registerFolderTreeRoot = () => {
+const registerTreeRoot = () => {
Navigation.register(new View({
id: folderTreeId,
@@ -188,8 +188,12 @@ const registerFolderTreeRoot = () => {
}))
}
-const registerFolderTreeChildren = async () => {
- await registerTreeNodes()
+export const registerFolderTreeView = async () => {
+ if (!isFolderTreeEnabled) {
+ return
+ }
+ registerTreeRoot()
+ await registerTreeChildren()
subscribe('files:node:created', onCreateNode)
subscribe('files:node:deleted', onDeleteNode)
subscribe('files:node:moved', onMoveNode)
@@ -197,11 +201,3 @@ const registerFolderTreeChildren = async () => {
// @ts-expect-error No payload
emit('files:folder-tree:initialized')
}
-
-export const registerFolderTreeView = async () => {
- if (!isFolderTreeEnabled) {
- return
- }
- registerFolderTreeRoot()
- await registerFolderTreeChildren()
-}