Merge pull request #579 from mpretty-cyro/fix/message-request-crash
Fix message request bugs
This commit is contained in:
commit
99da263a50
|
@ -176,7 +176,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
|
||||||
}
|
}
|
||||||
else if isMessageRequest && CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
else if isMessageRequest && CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
||||||
// If there are other interactions on this thread already then don't show the notification
|
// 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
|
CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,7 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup"
|
||||||
}
|
}
|
||||||
TSThread *thread = (TSThread *)object;
|
TSThread *thread = (TSThread *)object;
|
||||||
|
|
||||||
if (thread.isMessageRequest) {
|
if ([thread isMessageRequestUsingTransaction:transaction]) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -67,6 +67,8 @@ BOOL IsNoteToSelfEnabled(void);
|
||||||
*/
|
*/
|
||||||
- (NSUInteger)numberOfInteractions;
|
- (NSUInteger)numberOfInteractions;
|
||||||
|
|
||||||
|
- (NSUInteger)numberOfInteractionsWithTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||||
|
|
||||||
- (NSUInteger)unreadMessageCountWithTransaction:(YapDatabaseReadTransaction *)transaction
|
- (NSUInteger)unreadMessageCountWithTransaction:(YapDatabaseReadTransaction *)transaction
|
||||||
NS_SWIFT_NAME(unreadMessageCount(transaction:));
|
NS_SWIFT_NAME(unreadMessageCount(transaction:));
|
||||||
|
|
||||||
|
|
|
@ -233,12 +233,17 @@ BOOL IsNoteToSelfEnabled(void)
|
||||||
{
|
{
|
||||||
__block NSUInteger count;
|
__block NSUInteger count;
|
||||||
[[self dbReadConnection] readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
[[self dbReadConnection] readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||||
YapDatabaseViewTransaction *interactionsByThread = [transaction ext:TSMessageDatabaseViewExtensionName];
|
count = [self numberOfInteractionsWithTransaction:transaction];
|
||||||
count = [interactionsByThread numberOfItemsInGroup:self.uniqueId];
|
|
||||||
}];
|
}];
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSUInteger)numberOfInteractionsWithTransaction:(YapDatabaseReadTransaction *)transaction
|
||||||
|
{
|
||||||
|
YapDatabaseViewTransaction *interactionsByThread = [transaction ext:TSMessageDatabaseViewExtensionName];
|
||||||
|
return [interactionsByThread numberOfItemsInGroup:self.uniqueId];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSArray<id<OWSReadTracking>> *)unseenMessagesWithTransaction:(YapDatabaseReadTransaction *)transaction
|
- (NSArray<id<OWSReadTracking>> *)unseenMessagesWithTransaction:(YapDatabaseReadTransaction *)transaction
|
||||||
{
|
{
|
||||||
NSMutableArray<id<OWSReadTracking>> *messages = [NSMutableArray new];
|
NSMutableArray<id<OWSReadTracking>> *messages = [NSMutableArray new];
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
|
||||||
}
|
}
|
||||||
else if thread.isMessageRequest() && CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
else if thread.isMessageRequest() && CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
||||||
// If there are other interactions on this thread already then don't show the notification
|
// 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
|
CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] = false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue