diff options
author | Max <max@nextcloud.com> | 2022-02-21 14:01:07 +0300 |
---|---|---|
committer | Max <max@nextcloud.com> | 2022-03-02 10:18:04 +0300 |
commit | 7782f4ddfb05bbbb78f25778999c8b74290b4874 (patch) | |
tree | fc82f0ca75767db74936f73d6e347a7d8a9c3976 /src/helpers | |
parent | 2e80643ec45fce28ebecf1e0e2a57171d4ff1d80 (diff) |
use filelist PROPFIND for loading workspace
See #2171.
Even though this is meant to improve load times
I did not observe any improvements locally.
I suspect that is because the workspace was loaded in parallel with the PROPFIND anyway.
Experience may differ in production environments obviously.
It is still one request less and the code also seems more clean.
Signed-off-by: Max <max@nextcloud.com>
Diffstat (limited to 'src/helpers')
-rw-r--r-- | src/helpers/files.js | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/helpers/files.js b/src/helpers/files.js index 8d50a6a09..4551b5cea 100644 --- a/src/helpers/files.js +++ b/src/helpers/files.js @@ -136,6 +136,7 @@ const registerFileActionFallback = () => { const FilesWorkspacePlugin = { el: null, + vm: null, attach(fileList) { if (fileList.id !== 'files' && fileList.id !== 'files.public') { @@ -149,6 +150,21 @@ const FilesWorkspacePlugin = { render: this.render.bind(this), priority: 10, }) + + fileList.filesClient.addFileInfoParser((_response, data) => { + const dir = (data.mimetype === 'httpd/unix-directory') + ? data.path + (data.path.endsWith('/') ? '' : '/') + data.name + : data.path + if (dir !== fileList.getCurrentDirectory()) { + return + } + if (data.mimetype === 'httpd/unix-directory') { + this.vm.folder = { ...data } + } + if (data.mimetype === 'text/markdown' && data.name === 'Readme.md') { + this.vm.file = { ...data } + } + }) }, render(fileList) { @@ -163,21 +179,25 @@ const FilesWorkspacePlugin = { Vue.prototype.n = window.n Vue.prototype.OCA = window.OCA const View = Vue.extend(RichWorkspace) - const vm = new View({ + this.vm = new View({ propsData: { - path: fileList.getCurrentDirectory(), + file: null, + folder: null, }, store, }).$mount(this.el) fileList.$el.on('urlChanged', data => { - vm.path = data.dir.toString() + this.vm.file = null + this.vm.folder = null }) fileList.$el.on('changeDirectory', data => { - vm.path = data.dir.toString() + this.vm.file = null + this.vm.folder = null }) }) }, + } export { |