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

github.com/nextcloud/files_texteditor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-02-13 15:48:42 +0300
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-02-13 16:27:46 +0300
commit23b8eb4e0369e4fc219f17df3b0b1518dbfef545 (patch)
tree6a362d8199b2138d40dfc25f8328a4f620dbc9c4 /js
parentf1d3818f011a4e2bff0291af375e5d713f550907 (diff)
Do not keep FileInfoModels returned by "getModelForFile"
FileInfoModels returned by "getModelForFile" are just temporary, and they should be used and forgotten instead of being kept by apps. It is not guaranteed that different calls to "getModelForFile" for the same file returns the same FileInfoModel object, so changes in one model instance could be not known by other model instances (and their views), and this could lead to different bugs (for example, a file list entry being duplicated when a text file is edited or favourited after being created). Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'js')
-rw-r--r--js/editor.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/js/editor.js b/js/editor.js
index af0af6c..d4065ac 100644
--- a/js/editor.js
+++ b/js/editor.js
@@ -191,7 +191,7 @@ var Files_Texteditor = {
this.currentContext = context;
this.file.name = filename;
this.file.dir = context.dir;
- this.fileInfoModel = context.fileList.getModelForFile(filename);
+ this.fileList = context.fileList;
this.loadEditor(
OCA.Files_Texteditor.$container,
OCA.Files_Texteditor.file
@@ -616,10 +616,11 @@ var Files_Texteditor = {
this.$container.html('').show();
this.unloadControlBar();
this.unBindVisibleActions();
- if (this.fileInfoModel) {
- this.fileInfoModel.set({
+ var fileInfoModel = this.fileList.getModelForFile(this.file.name);
+ if (fileInfoModel) {
+ fileInfoModel.set({
// temp dummy, until we can do a PROPFIND
- etag: this.fileInfoModel.get('id') + this.file.mtime,
+ etag: fileInfoModel.get('id') + this.file.mtime,
mtime: this.file.mtime * 1000,
size: this.file.size
});