fix: enable global mark read on background update

This commit is contained in:
relikd
2025-07-21 13:19:13 +02:00
parent 131bfaa14d
commit 9c3814b470
2 changed files with 10 additions and 8 deletions

View File

@@ -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
}
}

View File

@@ -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:@"."];