Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368896

Summary: Favorites list not sorted
Product: [ECD] Orion Reporter: Andrew Eisenberg <andrew.eisenberg>
Component: ClientAssignee: Susan McCourt <susan>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 0.4   
Target Milestone: 0.4 M2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Andrew Eisenberg CLA 2012-01-17 18:43:31 EST
The favorites list in the navigator is not sorted.  It may be that they are sorted in the order that they are added.  Shouldn't the favorites be sorted alphabetically?
Comment 1 Andrew Eisenberg CLA 2012-01-17 19:54:23 EST
See pull request https://github.com/eclipse/orion.client/pull/13

The solution I implemented is to run a sort after any change to the favorites and stored searches in favorites.js.  It would certainly be nicer to not have to explicitly sort, but rather ensure that the arrays are implicitly sorted on each change (similar to a SortedSet in Java), but since there does not appear to be a simple way of doing this in javascript I think my current approach is sufficient.

I did not write any tests for this, but can if you would like me to.

I wrote all this code and have the rights to contribute it to Eclipse under the
eclipse.org web site terms of use.
Comment 2 Susan McCourt CLA 2012-01-18 11:41:36 EST
thanks, I'll take a look!
Comment 3 Andrew Eisenberg CLA 2012-01-18 17:37:36 EST
Forgot to mention that I was going to look at this.  :) 

Pull request:
https://github.com/eclipse/orion.client/pull/14

I decided to implement the sort from within the favorites service  (rather than in the UI).  This ensures that all clients of the favorites service receive favorites in the same order.  An argument can be made that it is the clients job to do the sorting since each client may want to do something different with the favorites, but I think this is likely to lead to code duplication since alphabetical ordering seems like the most likely ordering for all clients.

I wrote all this code and have the rights to contribute it to Eclipse under the eclipse.org web site terms of use.
Comment 4 Susan McCourt CLA 2012-01-20 18:02:17 EST
thanks, Andrew!
I agree with you that for now we may as well do it one place in the service.  There are many places in the UI where it would be nice to let the user sort (navigator, favorites, commits, etc.) but until we do that, we should at least have a reasonable/meaningful default.

I cherrypicked the commit and then followed it with a commit that removed the function "favoriteExists" as I assume this will arrive with the fix for bug 349785.  If it's not there, I'll add it back.
Comment 5 Susan McCourt CLA 2012-01-20 18:19:56 EST
(In reply to comment #4)

> I cherrypicked the commit and then followed it with a commit that removed the
> function "favoriteExists" as I assume this will arrive with the fix for bug
> 349785.  If it's not there, I'll add it back.

sorry, Andrew (Andy?).  I saw the "still can add duplicate favorites" bug go by today and thought that you had reopened the original bug about duplicates.  So I figured I'd commit this one first and wait for the fix to the other.

Now I see that you opened a different bug, so I could have committed them in the order you submitted, in which case that function would have already been added.