nextcloud/apps/files/tests/js
Daniel Calviño Sánchez be56374c51 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>
2017-07-05 15:01:23 +02:00
..
appSpec.js Do not encode slashes in "dir" URL param in files JS 2016-05-06 17:00:22 +02:00
breadcrumbSpec.js Parse backslash as directory separator in breadcrumb 2015-01-24 09:56:00 +01:00
detailsviewSpec.js Make possible to know the registered detail views in a details view 2017-06-09 03:14:23 +02:00
favoritesfilelistspec.js Make it possible to filter by tags with REPORT method 2016-10-19 11:06:29 +02:00
favoritespluginspec.js Added unit tests for right sidebar 2015-08-07 01:22:43 +02:00
fileUploadSpec.js Upload autorename on client side 2016-11-02 22:15:03 +01:00
fileactionsSpec.js fixes size of the download spinner 2016-05-30 11:23:54 +02:00
fileactionsmenuSpec.js Bring back file delete action text to be based on context 2015-12-11 15:14:30 +01:00
filelistSpec.js Fix sorting of favorite files 2017-07-05 15:01:23 +02:00
filesSpec.js Add ignore_files to config, 2017-03-20 01:17:12 -06:00
filesummarySpec.js Display number of hidden files in files summary (#25870) 2016-08-29 14:47:41 +02:00
mainfileinfodetailviewSpec.js Style modifications of favorite star on main detail view (#26658) 2016-12-19 17:34:09 +01:00
newfilemenuSpec.js Remove "Text file" entry in the "+" menu 2015-11-19 15:36:21 +01:00
tagspluginspec.js Fix favorite icon unit test for icon image 2016-02-25 23:01:09 +01:00