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
commit4062883459397b52964f8560c02516d18b7733ca (patch)
treee14636683ac991ffbd2bf4784c3586165471683c /apps/files
parent920a74118ce560c2d66940bad3b8a9d60bf86584 (diff)
downloadnextcloud-server-4062883459397b52964f8560c02516d18b7733ca.tar.gz
nextcloud-server-4062883459397b52964f8560c02516d18b7733ca.zip
fix(files): Respect "Show hidden files" setting in tree
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/src/views/folderTree.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/apps/files/src/views/folderTree.ts b/apps/files/src/views/folderTree.ts
index 4224012cd5b..d74f982afc9 100644
--- a/apps/files/src/views/folderTree.ts
+++ b/apps/files/src/views/folderTree.ts
@@ -28,6 +28,8 @@ import {
const isFolderTreeEnabled = loadState('files', 'config', { folder_tree: true }).folder_tree
+let showHiddenFiles = loadState('files', 'config', { show_hidden: false }).show_hidden
+
const Navigation = getNavigation()
const queue = new PQueue({ concurrency: 5, intervalCap: 5, interval: 200 })
@@ -63,6 +65,13 @@ const getLoadChildViews = (node: TreeNode | Folder) => {
}
const registerTreeNodeView = (node: TreeNode) => {
+ const registeredView = Navigation.views.find(view => view.id === encodeSource(node.source))
+ if (registeredView) {
+ Navigation.remove(registeredView.id)
+ }
+ if (!showHiddenFiles && node.basename.startsWith('.')) {
+ return
+ }
Navigation.register(new View({
id: encodeSource(node.source),
parent: getSourceParent(node.source),
@@ -84,6 +93,9 @@ const registerTreeNodeView = (node: TreeNode) => {
}
const registerFolderView = (folder: Folder) => {
+ if (!showHiddenFiles && folder.basename.startsWith('.')) {
+ return
+ }
Navigation.register(new View({
id: getFolderTreeViewId(folder),
parent: getFolderTreeParentId(folder),
@@ -153,6 +165,15 @@ const onMoveNode = ({ node, oldSource }) => {
}
}
+const onUserConfigUpdated = async ({ key, value }) => {
+ if (key === 'show_hidden') {
+ showHiddenFiles = value
+ await registerTreeNodes()
+ // @ts-expect-error No payload
+ emit('files:folder-tree:initialized')
+ }
+}
+
const registerFolderTreeRoot = () => {
Navigation.register(new View({
id: folderTreeId,
@@ -172,6 +193,7 @@ const registerFolderTreeChildren = async () => {
subscribe('files:node:created', onCreateNode)
subscribe('files:node:deleted', onDeleteNode)
subscribe('files:node:moved', onMoveNode)
+ subscribe('files:config:updated', onUserConfigUpdated)
// @ts-expect-error No payload
emit('files:folder-tree:initialized')
}