Mark individual menu items un/read with option click
This commit is contained in:
@@ -76,16 +76,18 @@
|
|||||||
|
|
||||||
/// Callback method for @c NSMenuItem. Will open url associated with @c FeedArticle and mark it read.
|
/// Callback method for @c NSMenuItem. Will open url associated with @c FeedArticle and mark it read.
|
||||||
+ (void)didClickOnMenuItem:(NSMenuItem*)sender {
|
+ (void)didClickOnMenuItem:(NSMenuItem*)sender {
|
||||||
|
BOOL flipUnread = (([NSEvent modifierFlags] & NSEventModifierFlagOption) != 0);
|
||||||
NSManagedObjectContext *moc = [StoreCoordinator createChildContext];
|
NSManagedObjectContext *moc = [StoreCoordinator createChildContext];
|
||||||
FeedArticle *fa = [moc objectWithID:sender.representedObject];
|
FeedArticle *fa = [moc objectWithID:sender.representedObject];
|
||||||
NSString *url = fa.link;
|
NSString *url = fa.link;
|
||||||
if (fa.unread) {
|
if (flipUnread || fa.unread) {
|
||||||
fa.unread = NO;
|
fa.unread = !fa.unread;
|
||||||
|
NSNumber *num = (fa.unread ? @+1 : @-1);
|
||||||
[StoreCoordinator saveContext:moc andParent:YES];
|
[StoreCoordinator saveContext:moc andParent:YES];
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTotalUnreadCountChanged object:@-1];
|
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTotalUnreadCountChanged object:num];
|
||||||
}
|
}
|
||||||
[moc reset];
|
[moc reset];
|
||||||
if (url && url.length > 0)
|
if (url && url.length > 0 && !flipUnread) // flipUnread == change unread state
|
||||||
[UserPrefs openURLsWithPreferredBrowser:@[[NSURL URLWithString:url]]];
|
[UserPrefs openURLsWithPreferredBrowser:@[[NSURL URLWithString:url]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user