Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax <max@nextcloud.com>2022-02-24 17:09:12 +0300
committerMax <max@nextcloud.com>2022-03-02 10:20:23 +0300
commitaf0253afda35391ca66eff415e75d3d5e8d5a6f9 (patch)
tree47f900bfda8561e1653b9deec85458829eedc023 /src
parent8bd6b0c4d690662d1687261aaeebbed53696efa1 (diff)
fix: use file id to identify readme for workspace
In public shares data did not include a name if i remember correctly. When the Readme gets created it will trigger a PROPFIND but that will only look for the Readme itself - not the entire directory. Also detect that Readme so the view gets updated and shows the rich workspace when a Readme.md is created. This covers the main usecase that people click on the empty workspace. It does not cover creating a localized readme file or one named README.md or so. We also did not cover that before - so this seems okay. Signed-off-by: Max <max@nextcloud.com>
Diffstat (limited to 'src')
-rw-r--r--src/helpers/files.js42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/helpers/files.js b/src/helpers/files.js
index 2a2de1d0d..d48401950 100644
--- a/src/helpers/files.js
+++ b/src/helpers/files.js
@@ -161,29 +161,37 @@ const FilesWorkspacePlugin = {
]
}
- let filename = null
+ let readmeId = null
fileList.filesClient.addFileInfoParser((response, data) => {
if (data.mimetype === 'httpd/unix-directory') {
const props = response.propStat[0].properties
- filename = props[PROPERTY_WORKSPACE_FILE]
- const dir = (data.mimetype === 'httpd/unix-directory')
- ? data.path + (data.path.endsWith('/') ? '' : '/') + data.name
- : data.path
+ const dir = data.path + (data.path.endsWith('/') ? '' : '/') + data.name
if (dir === fileList.getCurrentDirectory()) {
+ readmeId = props[PROPERTY_WORKSPACE_FILE]
this.vm.folder = {
- ...data,
+ permissions: data.permissions,
}
+ this.vm.loaded = true
+ // in case no file is found we are done
+ this.vm.ready = true
}
}
- if (data.mimetype === 'text/markdown') {
- const name = filename || 'Readme.md'
- if (data.name === name) {
- this.vm.file = {
- ...data,
- id: parseInt(data.id),
- }
+ if (readmeId && data.id === readmeId) {
+ if (data.mimetype !== 'text/markdown') {
+ console.warn('Expected workspace file to be markdown:', data)
}
+ this.open(data)
+ return
+ }
+ /*
+ * Handle the creation of 'Readme.md'.
+ * The PROPFIND after the creation does not include the parent dir.
+ */
+ if (data.name === 'Readme.md'
+ && data.mimetype === 'text/markdown'
+ && data.path === fileList.getCurrentDirectory()) {
+ this.open(data)
}
})
@@ -220,6 +228,14 @@ const FilesWorkspacePlugin = {
})
},
+ open(data) {
+ this.vm.file = {
+ ...data,
+ id: parseInt(data.id),
+ }
+ // waiting for the editor to be ready
+ this.vm.ready = false
+ },
}
export {