fix: better handling of open-a-few limit
This commit is contained in:
@@ -74,14 +74,16 @@
|
|||||||
[menu insertDefaultHeader];
|
[menu insertDefaultHeader];
|
||||||
NSInteger mc = UserPrefsInt(Pref_articleCountLimit);
|
NSInteger mc = UserPrefsInt(Pref_articleCountLimit);
|
||||||
if (mc < 0) mc = NSIntegerMax;
|
if (mc < 0) mc = NSIntegerMax;
|
||||||
BOOL onlyUnread = UserPrefsBool(Pref_articleUnreadOnly);
|
if (mc > 0) {
|
||||||
|
BOOL onlyUnread = UserPrefsBool(Pref_articleUnreadOnly);
|
||||||
|
|
||||||
for (FeedArticle *fa in sortedList) {
|
for (FeedArticle *fa in sortedList) {
|
||||||
if (onlyUnread && !fa.unread && !_showHidden)
|
if (onlyUnread && !fa.unread && !_showHidden)
|
||||||
continue;
|
continue;
|
||||||
if (--mc < 0) // mc == 0 will first decrement to -1, then evaluate
|
if (--mc < 0) // mc == 0 will first decrement to -1, then evaluate
|
||||||
break;
|
break;
|
||||||
[menu addItem:[fa newMenuItem]];
|
[menu addItem:[fa newMenuItem]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[menu setHeaderHasUnread:self.unreadMap[menu.titleIndexPath]];
|
[menu setHeaderHasUnread:self.unreadMap[menu.titleIndexPath]];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,8 +75,11 @@ typedef NS_ENUM(NSInteger, MenuItemTag) {
|
|||||||
self.autoenablesItems = NO;
|
self.autoenablesItems = NO;
|
||||||
NSMenuItem *itm = [self addItemIfAllowed:TagOpenAllUnread title:NSLocalizedString(@"Open all unread", nil)];
|
NSMenuItem *itm = [self addItemIfAllowed:TagOpenAllUnread title:NSLocalizedString(@"Open all unread", nil)];
|
||||||
if (itm) {
|
if (itm) {
|
||||||
NSString *altTitle = [NSString stringWithFormat:NSLocalizedString(@"Open a few unread (%lu)", nil), UserPrefsUInt(Pref_openFewLinksLimit)];
|
NSInteger limit = UserPrefsInt(Pref_openFewLinksLimit);
|
||||||
[self addItem:[itm alternateWithTitle:altTitle]];
|
if (limit > 0) {
|
||||||
|
NSString *altTitle = [NSString stringWithFormat:NSLocalizedString(@"Open a few unread (%ld)", nil), limit];
|
||||||
|
[self addItem:[itm alternateWithTitle:altTitle]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[self addItemIfAllowed:TagMarkAllRead title:NSLocalizedString(@"Mark all read", nil)];
|
[self addItemIfAllowed:TagMarkAllRead title:NSLocalizedString(@"Mark all read", nil)];
|
||||||
[self addItemIfAllowed:TagMarkAllUnread title:NSLocalizedString(@"Mark all unread", nil)];
|
[self addItemIfAllowed:TagMarkAllUnread title:NSLocalizedString(@"Mark all unread", nil)];
|
||||||
@@ -165,7 +168,7 @@ typedef NS_ENUM(NSInteger, MenuItemTag) {
|
|||||||
BOOL openLinks = NO;
|
BOOL openLinks = NO;
|
||||||
NSUInteger limit = 0;
|
NSUInteger limit = 0;
|
||||||
if (sender.tag == TagOpenAllUnread) {
|
if (sender.tag == TagOpenAllUnread) {
|
||||||
if (sender.isAlternate)
|
if (sender.isAlternate) // if reaches this far, limit is guaranteed to be >0
|
||||||
limit = UserPrefsUInt(Pref_openFewLinksLimit);
|
limit = UserPrefsUInt(Pref_openFewLinksLimit);
|
||||||
openLinks = YES;
|
openLinks = YES;
|
||||||
} else if (sender.tag != TagMarkAllRead && sender.tag != TagMarkAllUnread) {
|
} else if (sender.tag != TagMarkAllRead && sender.tag != TagMarkAllUnread) {
|
||||||
|
|||||||
Reference in New Issue
Block a user