feat: no global notify if marking articles read
This commit is contained in:
@@ -8,7 +8,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface NotifyEndpoint : NSObject <UNUserNotificationCenterDelegate>
|
||||
+ (void)activate;
|
||||
|
||||
+ (void)setGlobalCount:(NSUInteger)count;
|
||||
+ (void)setGlobalCount:(NSInteger)count previousCount:(NSInteger)count;
|
||||
+ (void)postFeed:(Feed*)feed;
|
||||
+ (void)postArticle:(FeedArticle*)article;
|
||||
|
||||
|
||||
@@ -45,17 +45,19 @@ static NotificationType notifyType;
|
||||
}
|
||||
|
||||
/// Set (or update) global "X unread articles"
|
||||
+ (void)setGlobalCount:(NSUInteger)count {
|
||||
+ (void)setGlobalCount:(NSInteger)newCount previousCount:(NSInteger)oldCount {
|
||||
if (notifyType != NotificationTypeGlobal) {
|
||||
return;
|
||||
}
|
||||
if (count > 0) {
|
||||
if (newCount > 0) {
|
||||
// TODO: how to handle global count updates?
|
||||
// ignore and keep old count until 0?
|
||||
// or update count and show a new notification banner?
|
||||
[self send:kNotifyIdGlobal
|
||||
title:nil
|
||||
body:[NSString stringWithFormat:@"%ld unread articles", count]];
|
||||
if (newCount > oldCount) { // only notify if new feeds (quirk: will also trigger for option-click menu to mark unread)
|
||||
[self send:kNotifyIdGlobal
|
||||
title:nil
|
||||
body:[NSString stringWithFormat:@"%ld unread articles", newCount]];
|
||||
}
|
||||
} else {
|
||||
[self dismiss:@[kNotifyIdGlobal]];
|
||||
}
|
||||
|
||||
@@ -70,19 +70,21 @@
|
||||
|
||||
/// Assign total unread count value directly.
|
||||
- (void)setUnreadCountAbsolute:(NSUInteger)count {
|
||||
NSInteger oldCount = _unreadCountTotal;
|
||||
_unreadCountTotal = count > 0 ? (NSInteger)count : 0;
|
||||
[self updateBarIcon];
|
||||
[NotifyEndpoint setGlobalCount:count];
|
||||
[NotifyEndpoint setGlobalCount:_unreadCountTotal previousCount:oldCount];
|
||||
}
|
||||
|
||||
/// Assign new value by adding @c count to total unread count (may be negative).
|
||||
- (void)setUnreadCountRelative:(NSInteger)count {
|
||||
NSInteger oldCount = _unreadCountTotal;
|
||||
_unreadCountTotal += count;
|
||||
if (_unreadCountTotal < 0) {
|
||||
_unreadCountTotal = 0;
|
||||
}
|
||||
[self updateBarIcon];
|
||||
[NotifyEndpoint setGlobalCount:(NSUInteger)_unreadCountTotal];
|
||||
[NotifyEndpoint setGlobalCount:_unreadCountTotal previousCount:oldCount];
|
||||
}
|
||||
|
||||
/// Fetch new total unread count from core data and assign it as new value (dispatch async on main thread).
|
||||
|
||||
Reference in New Issue
Block a user