diff --git a/Session/Notifications/AppNotifications.swift b/Session/Notifications/AppNotifications.swift index c4118e3a6..5b38771cd 100644 --- a/Session/Notifications/AppNotifications.swift +++ b/Session/Notifications/AppNotifications.swift @@ -175,7 +175,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol { } else if thread.isMessageRequest() && CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] { // If there are other interactions on this thread already then don't show the notification - if thread.numberOfInteractions() > 1 { return } + if thread.numberOfInteractions(with: transaction) > 1 { return } CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] = false } diff --git a/SessionMessagingKit/Threads/TSThread.h b/SessionMessagingKit/Threads/TSThread.h index 0542b390a..dbb38ed20 100644 --- a/SessionMessagingKit/Threads/TSThread.h +++ b/SessionMessagingKit/Threads/TSThread.h @@ -67,6 +67,8 @@ BOOL IsNoteToSelfEnabled(void); */ - (NSUInteger)numberOfInteractions; +- (NSUInteger)numberOfInteractionsWithTransaction:(YapDatabaseReadTransaction *)transaction; + - (NSUInteger)unreadMessageCountWithTransaction:(YapDatabaseReadTransaction *)transaction NS_SWIFT_NAME(unreadMessageCount(transaction:)); diff --git a/SessionMessagingKit/Threads/TSThread.m b/SessionMessagingKit/Threads/TSThread.m index a848527bc..0f9a5cc9a 100644 --- a/SessionMessagingKit/Threads/TSThread.m +++ b/SessionMessagingKit/Threads/TSThread.m @@ -233,12 +233,17 @@ BOOL IsNoteToSelfEnabled(void) { __block NSUInteger count; [[self dbReadConnection] readWithBlock:^(YapDatabaseReadTransaction *transaction) { - YapDatabaseViewTransaction *interactionsByThread = [transaction ext:TSMessageDatabaseViewExtensionName]; - count = [interactionsByThread numberOfItemsInGroup:self.uniqueId]; + count = [self numberOfInteractionsWithTransaction:transaction]; }]; return count; } +- (NSUInteger)numberOfInteractionsWithTransaction:(YapDatabaseReadTransaction *)transaction +{ + YapDatabaseViewTransaction *interactionsByThread = [transaction ext:TSMessageDatabaseViewExtensionName]; + return [interactionsByThread numberOfItemsInGroup:self.uniqueId]; +} + - (NSArray> *)unseenMessagesWithTransaction:(YapDatabaseReadTransaction *)transaction { NSMutableArray> *messages = [NSMutableArray new]; diff --git a/SessionNotificationServiceExtension/NSENotificationPresenter.swift b/SessionNotificationServiceExtension/NSENotificationPresenter.swift index 2d0b658f1..6e330b94a 100644 --- a/SessionNotificationServiceExtension/NSENotificationPresenter.swift +++ b/SessionNotificationServiceExtension/NSENotificationPresenter.swift @@ -22,7 +22,7 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol { } else if thread.isMessageRequest() && CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] { // If there are other interactions on this thread already then don't show the notification - if thread.numberOfInteractions() > 1 { return } + if thread.numberOfInteractions(with: transaction) > 1 { return } CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] = false }