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
|
||||
NSArray<UnreadTotal*> *itms = [self.unreadMap itemsForPath:item.submenu.titleIndexPath create:NO];
|
||||
for (UnreadTotal *uct in itms.reverseObjectEnumerator) {
|
||||
if (item) { // nil on last loop (aka main menu, see below)
|
||||
[item.submenu setHeaderHasUnread:uct];
|
||||
[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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,15 +14,12 @@
|
||||
- (instancetype)initWithCoreData:(NSArray<NSDictionary*>*)data {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
UnreadTotal *sum = [UnreadTotal new];
|
||||
_map = [NSMutableDictionary dictionaryWithCapacity:data.count];
|
||||
_map[@""] = sum;
|
||||
_map = [NSMutableDictionary dictionaryWithCapacity:data.count + 1];
|
||||
_map[@""] = [UnreadTotal new];
|
||||
|
||||
for (NSDictionary *d in data) {
|
||||
NSUInteger u = [d[@"unread"] unsignedIntegerValue];
|
||||
NSUInteger t = [d[@"total"] unsignedIntegerValue];
|
||||
sum.unread += u;
|
||||
sum.total += t;
|
||||
|
||||
for (UnreadTotal *uct in [self itemsForPath:d[@"indexPath"] create:YES]) {
|
||||
uct.unread += u;
|
||||
@@ -37,6 +34,7 @@
|
||||
- (NSArray<UnreadTotal*>*)itemsForPath:(NSString*)path create:(BOOL)flag {
|
||||
NSMutableArray<UnreadTotal*> *arr = [NSMutableArray array];
|
||||
NSMutableString *key = [NSMutableString string];
|
||||
[arr addObject:_map[@""]];
|
||||
for (NSString *idx in [path componentsSeparatedByString:@"."]) {
|
||||
if (key.length > 0)
|
||||
[key appendString:@"."];
|
||||
|
||||
Reference in New Issue
Block a user