summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-07-05 15:01:23 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-07-05 15:01:23 +0200
commitbe56374c517633d895e245916e047a72e6723038 (patch)
treea7a61d32191a5154acb847b9f83153e141e32f2d /core/js
parent6fa5c33af4a214e695942e05bb50f564e09d1f44 (diff)
downloadnextcloud-server-be56374c517633d895e245916e047a72e6723038.tar.gz
nextcloud-server-be56374c517633d895e245916e047a72e6723038.zip
Fix sorting of favorite files
The sort comparator checks the "isFavorite" property of the FileInfo objects to compare. That property is set when the file list is loaded and the response from the server is parsed, and thus a freshly loaded file list has the proper sorting for favorite files. However, the property is not set in other cases, like when the FileInfo objects are derived from FileInfoModels due to a file being marked as a favorite or a text editor being closed, which causes the file to be sorted in the wrong position. There is no need to add the property in those situations, though; in all cases the TagsPlugin adds a "tags" array property that contains an OC.TAG_FAVORITE tag, so that tag can be checked instead of "isFavorite". Moreover, although "isFavorite" was added by the main "_parseFileInfo" function it did not really belong there but to the "FileInfoParser" from the TagsPlugin; however, as that property now is not used anywhere it was removed altogether. A cleaner solution would have been to make the sort comparator extensible by plugins like other behaviours of the file list and then add the sorting logic related to favorite files to the TagsPlugin. However, right now only the TagsPlugin would need to alter the main sorting logic, and it seems like a corner case anyway. Even if it is implemented as a plugin, favorite files is a core feature, so for the time being it will be taken into account directly in the main sorting logic; making the sort comparator extensible by plugins is defered until there are other use cases for that. Fixes #5410 Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'core/js')
-rw-r--r--core/js/files/client.js7
-rw-r--r--core/js/files/fileinfo.js7
2 files changed, 1 insertions, 13 deletions
diff --git a/core/js/files/client.js b/core/js/files/client.js
index da8a1205e4b..d8e615f6d6d 100644
--- a/core/js/files/client.js
+++ b/core/js/files/client.js
@@ -304,13 +304,6 @@
data.hasPreview = true;
}
- var isFavorite = props['{' + Client.NS_OWNCLOUD + '}favorite'];
- if (!_.isUndefined(isFavorite)) {
- data.isFavorite = isFavorite === '1';
- } else {
- data.isFavorite = false;
- }
-
var contentType = props[Client.PROPERTY_GETCONTENTTYPE];
if (!_.isUndefined(contentType)) {
data.mimetype = contentType;
diff --git a/core/js/files/fileinfo.js b/core/js/files/fileinfo.js
index 7c8e4586448..1fc239da47a 100644
--- a/core/js/files/fileinfo.js
+++ b/core/js/files/fileinfo.js
@@ -132,12 +132,7 @@
/**
* @type boolean
*/
- hasPreview: true,
-
- /**
- * @type boolean
- */
- isFavorite: false
+ hasPreview: true
};
if (!OC.Files) {