Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syncthing/STApplication.m: Sort folders submenu ascending (fixes #49) #51

Closed
wants to merge 1 commit into from

Conversation

xor-gate
Copy link
Member

@xor-gate xor-gate commented Jul 3, 2018

PR is deprecated in favor of #53. I made the decision we need a master, and develop branch.

@@ -163,7 +163,13 @@ - (IBAction) clickedOpen:(id)sender {
- (void) updateFoldersMenu:(NSMenu *)menu {
[menu removeAllItems];

for (id dir in [self.syncthing getFolders]) {
// Get folders from syncthing and sort ascending
NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"label" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work without a comparator. NSSortDescriptor defaults to compare: anyway.

NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"label" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) {
return [(NSString *)obj1 compare:(NSString *)obj2 options:NSNumericSearch];
}];
NSArray *folders = [[self.syncthing getFolders] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrayWithObject: can be replaced with just @[sort].

@xor-gate xor-gate closed this Jul 3, 2018
@xor-gate xor-gate reopened this Jul 3, 2018
@xor-gate xor-gate closed this Jul 3, 2018
@syncthing syncthing locked and limited conversation to collaborators Jul 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants