fix: enable global mark read on background update
This commit is contained in:
@@ -129,10 +129,14 @@
|
|||||||
// 3. set unread count & enabled header for all parents
|
// 3. set unread count & enabled header for all parents
|
||||||
NSArray<UnreadTotal*> *itms = [self.unreadMap itemsForPath:item.submenu.titleIndexPath create:NO];
|
NSArray<UnreadTotal*> *itms = [self.unreadMap itemsForPath:item.submenu.titleIndexPath create:NO];
|
||||||
for (UnreadTotal *uct in itms.reverseObjectEnumerator) {
|
for (UnreadTotal *uct in itms.reverseObjectEnumerator) {
|
||||||
[item.submenu setHeaderHasUnread:uct];
|
if (item) { // nil on last loop (aka main menu, see below)
|
||||||
[item setTitleCount:uct.unread];
|
[item.submenu setHeaderHasUnread:uct];
|
||||||
item = item.parentItem;
|
[item setTitleCount:uct.unread];
|
||||||
|
item = item.parentItem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// call on main menu
|
||||||
|
[self.statusItem.mainMenu setHeaderHasUnread:itms.firstObject];
|
||||||
// TODO: need to re-create groups if user chose to hide already read articles
|
// TODO: need to re-create groups if user chose to hide already read articles
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,12 @@
|
|||||||
- (instancetype)initWithCoreData:(NSArray<NSDictionary*>*)data {
|
- (instancetype)initWithCoreData:(NSArray<NSDictionary*>*)data {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
UnreadTotal *sum = [UnreadTotal new];
|
_map = [NSMutableDictionary dictionaryWithCapacity:data.count + 1];
|
||||||
_map = [NSMutableDictionary dictionaryWithCapacity:data.count];
|
_map[@""] = [UnreadTotal new];
|
||||||
_map[@""] = sum;
|
|
||||||
|
|
||||||
for (NSDictionary *d in data) {
|
for (NSDictionary *d in data) {
|
||||||
NSUInteger u = [d[@"unread"] unsignedIntegerValue];
|
NSUInteger u = [d[@"unread"] unsignedIntegerValue];
|
||||||
NSUInteger t = [d[@"total"] unsignedIntegerValue];
|
NSUInteger t = [d[@"total"] unsignedIntegerValue];
|
||||||
sum.unread += u;
|
|
||||||
sum.total += t;
|
|
||||||
|
|
||||||
for (UnreadTotal *uct in [self itemsForPath:d[@"indexPath"] create:YES]) {
|
for (UnreadTotal *uct in [self itemsForPath:d[@"indexPath"] create:YES]) {
|
||||||
uct.unread += u;
|
uct.unread += u;
|
||||||
@@ -37,6 +34,7 @@
|
|||||||
- (NSArray<UnreadTotal*>*)itemsForPath:(NSString*)path create:(BOOL)flag {
|
- (NSArray<UnreadTotal*>*)itemsForPath:(NSString*)path create:(BOOL)flag {
|
||||||
NSMutableArray<UnreadTotal*> *arr = [NSMutableArray array];
|
NSMutableArray<UnreadTotal*> *arr = [NSMutableArray array];
|
||||||
NSMutableString *key = [NSMutableString string];
|
NSMutableString *key = [NSMutableString string];
|
||||||
|
[arr addObject:_map[@""]];
|
||||||
for (NSString *idx in [path componentsSeparatedByString:@"."]) {
|
for (NSString *idx in [path componentsSeparatedByString:@"."]) {
|
||||||
if (key.length > 0)
|
if (key.length > 0)
|
||||||
[key appendString:@"."];
|
[key appendString:@"."];
|
||||||
|
|||||||
Reference in New Issue
Block a user