mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
iOS: #1227 (feed order preference)
Note that need to pull-to-refresh to make the preference take effect, since it sorts on loading the feeds. I think that’s reasonable; not something people would change often.
This commit is contained in:
parent
2140d47561
commit
ed5600ac0b
5 changed files with 79 additions and 18 deletions
|
@ -421,6 +421,7 @@ SFSafariViewControllerDelegate> {
|
|||
- (NSString *)extractFolderName:(NSString *)folderName;
|
||||
- (NSString *)extractParentFolderName:(NSString *)folderName;
|
||||
- (NSArray *)parentFoldersForFeed:(NSString *)feedId;
|
||||
- (NSDictionary *)getFeedWithId:(id)feedId;
|
||||
- (NSDictionary *)getFeed:(NSString *)feedId;
|
||||
- (NSDictionary *)getStory:(NSString *)storyHash;
|
||||
|
||||
|
|
|
@ -3001,6 +3001,12 @@
|
|||
return uniqueFolderNames;
|
||||
}
|
||||
|
||||
- (NSDictionary *)getFeedWithId:(id)feedId {
|
||||
NSString *feedIdStr = [NSString stringWithFormat:@"%@", feedId];
|
||||
|
||||
return [self getFeed:feedIdStr];
|
||||
}
|
||||
|
||||
- (NSDictionary *)getFeed:(NSString *)feedId {
|
||||
NSDictionary *feed;
|
||||
if (storiesCollection.isSocialView ||
|
||||
|
|
|
@ -723,6 +723,17 @@ static NSArray<NSString *> *NewsBlurTopSectionNames;
|
|||
[appDelegate populateDictUnreadCounts];
|
||||
[appDelegate populateDictTextFeeds];
|
||||
|
||||
NSString *sortOrder = [userPreferences stringForKey:@"feed_list_sort_order"];
|
||||
BOOL sortByMostUsed = [sortOrder isEqualToString:@"usage"];
|
||||
|
||||
NSMutableArray *sortDescriptors = [NSMutableArray array];
|
||||
|
||||
if (sortByMostUsed) {
|
||||
[sortDescriptors addObject:[NSSortDescriptor sortDescriptorWithKey:@"feed_opens" ascending:NO]];
|
||||
}
|
||||
|
||||
[sortDescriptors addObject:[NSSortDescriptor sortDescriptorWithKey:@"feed_title" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]];
|
||||
|
||||
// sort all the folders
|
||||
appDelegate.dictFoldersArray = [NSMutableArray array];
|
||||
for (id f in appDelegate.dictFolders) {
|
||||
|
@ -734,27 +745,30 @@ static NSArray<NSString *> *NewsBlurTopSectionNames;
|
|||
folderTitle = f;
|
||||
}
|
||||
[appDelegate.dictFoldersArray addObject:folderTitle];
|
||||
sortedArray = [folder sortedArrayUsingComparator:^NSComparisonResult(id id1, id id2) {
|
||||
NSString *feedTitleA;
|
||||
NSString *feedTitleB;
|
||||
|
||||
NSMutableArray *feeds = [NSMutableArray array];
|
||||
|
||||
for (id feedId in folder) {
|
||||
NSString *feedIdStr = [NSString stringWithFormat:@"%@", feedId];
|
||||
NSDictionary *feed;
|
||||
|
||||
if ([appDelegate isSocialFeed:[NSString stringWithFormat:@"%@", id1]]) {
|
||||
feedTitleA = [[appDelegate.dictSocialFeeds
|
||||
objectForKey:[NSString stringWithFormat:@"%@", id1]]
|
||||
objectForKey:@"feed_title"];
|
||||
feedTitleB = [[appDelegate.dictSocialFeeds
|
||||
objectForKey:[NSString stringWithFormat:@"%@", id2]]
|
||||
objectForKey:@"feed_title"];
|
||||
if ([appDelegate isSavedFeed:feedIdStr]) {
|
||||
feed = @{@"id" : feedId};
|
||||
} else if ([appDelegate isSocialFeed:feedIdStr]) {
|
||||
feed = appDelegate.dictSocialFeeds[feedIdStr];
|
||||
} else {
|
||||
feedTitleA = [[appDelegate.dictFeeds
|
||||
objectForKey:[NSString stringWithFormat:@"%@", id1]]
|
||||
objectForKey:@"feed_title"];
|
||||
feedTitleB = [[appDelegate.dictFeeds
|
||||
objectForKey:[NSString stringWithFormat:@"%@", id2]]
|
||||
objectForKey:@"feed_title"];
|
||||
feed = appDelegate.dictFeeds[feedIdStr];
|
||||
}
|
||||
return [feedTitleA caseInsensitiveCompare:feedTitleB];
|
||||
}];
|
||||
|
||||
if (feed != nil) {
|
||||
[feeds addObject:feed];
|
||||
}
|
||||
}
|
||||
|
||||
NSArray *sortedFeeds = [feeds sortedArrayUsingDescriptors:sortDescriptors];
|
||||
|
||||
sortedArray = [sortedFeeds valueForKey:@"id"];
|
||||
|
||||
[sortedFolders setValue:sortedArray forKey:folderTitle];
|
||||
}
|
||||
appDelegate.dictFolders = sortedFolders;
|
||||
|
|
|
@ -204,6 +204,26 @@
|
|||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSMultiValueSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>Feed list order</string>
|
||||
<key>Titles</key>
|
||||
<array>
|
||||
<string>Alphabetical</string>
|
||||
<string>Most used then alphabetical</string>
|
||||
</array>
|
||||
<key>DefaultValue</key>
|
||||
<string>title</string>
|
||||
<key>Values</key>
|
||||
<array>
|
||||
<string>title</string>
|
||||
<string>usage</string>
|
||||
</array>
|
||||
<key>Key</key>
|
||||
<string>feed_list_sort_order</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSToggleSwitchSpecifier</string>
|
||||
|
|
|
@ -224,6 +224,26 @@
|
|||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSMultiValueSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>Feed list order</string>
|
||||
<key>Titles</key>
|
||||
<array>
|
||||
<string>Alphabetical</string>
|
||||
<string>Most used then alphabetical</string>
|
||||
</array>
|
||||
<key>DefaultValue</key>
|
||||
<string>title</string>
|
||||
<key>Values</key>
|
||||
<array>
|
||||
<string>title</string>
|
||||
<string>usage</string>
|
||||
</array>
|
||||
<key>Key</key>
|
||||
<string>feed_list_sort_order</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSToggleSwitchSpecifier</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue