mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge pull request #478 from RyanRory/fine-grained-notification-settings-2
Fix Mentions Only Notification Issues
This commit is contained in:
commit
b1e500d256
9 changed files with 17 additions and 16 deletions
|
@ -1,19 +1,8 @@
|
||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"filename" : "ic_notification_mentions.png",
|
"filename" : "ic_notifications_mentions.pdf",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal"
|
||||||
"scale" : "1x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename" : "ic_notification_mentions-1.png",
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "2x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename" : "ic_notification_mentions-2.png",
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "3x"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info" : {
|
"info" : {
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
BIN
Session/Meta/Images.xcassets/Session/NotifyMentions.imageset/ic_notifications_mentions.pdf
vendored
Normal file
BIN
Session/Meta/Images.xcassets/Session/NotifyMentions.imageset/ic_notifications_mentions.pdf
vendored
Normal file
Binary file not shown.
|
@ -168,8 +168,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
|
||||||
|
|
||||||
// Don't fire the notification if the current user isn't mentioned
|
// Don't fire the notification if the current user isn't mentioned
|
||||||
// and isOnlyNotifyingForMentions is on.
|
// and isOnlyNotifyingForMentions is on.
|
||||||
let isUserMentioned = MentionUtilities.isUserMentioned(in: messageText ?? "")
|
if let groupThread = thread as? TSGroupThread, groupThread.isOnlyNotifyingForMentions && !incomingMessage.isUserMentioned {
|
||||||
if let groupThread = thread as? TSGroupThread, groupThread.isOnlyNotifyingForMentions && !isUserMentioned {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@property (nonatomic, readonly) BOOL wasReceivedByUD;
|
@property (nonatomic, readonly) BOOL wasReceivedByUD;
|
||||||
|
|
||||||
|
@property (nonatomic, readonly) BOOL isUserMentioned;
|
||||||
|
|
||||||
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
|
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
|
||||||
inThread:(nullable TSThread *)thread
|
inThread:(nullable TSThread *)thread
|
||||||
messageBody:(nullable NSString *)body
|
messageBody:(nullable NSString *)body
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#import "TSGroupThread.h"
|
#import "TSGroupThread.h"
|
||||||
#import <YapDatabase/YapDatabaseConnection.h>
|
#import <YapDatabase/YapDatabaseConnection.h>
|
||||||
#import <SessionUtilitiesKit/SessionUtilitiesKit.h>
|
#import <SessionUtilitiesKit/SessionUtilitiesKit.h>
|
||||||
|
#import <SessionMessagingKit/SessionMessagingKit-Swift.h>
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@ -121,6 +122,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
return self.isExpiringMessage;
|
return self.isExpiringMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)isUserMentioned
|
||||||
|
{
|
||||||
|
NSString *userPublicKey = [SNGeneralUtilities getUserPublicKey];
|
||||||
|
return (self.body != nil && [self.body containsString:[NSString stringWithFormat:@"@%@", userPublicKey]]) || (self.quotedMessage != nil && [self.quotedMessage.authorId isEqualToString:userPublicKey]);
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - OWSReadTracking
|
#pragma mark - OWSReadTracking
|
||||||
|
|
||||||
- (BOOL)shouldAffectUnreadCounts
|
- (BOOL)shouldAffectUnreadCounts
|
||||||
|
|
|
@ -73,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
YapDatabaseViewTransaction *unreadMessages = [transaction ext:TSUnreadDatabaseViewExtensionName];
|
YapDatabaseViewTransaction *unreadMessages = [transaction ext:TSUnreadDatabaseViewExtensionName];
|
||||||
NSArray<NSString *> *allGroups = [unreadMessages allGroups];
|
NSArray<NSString *> *allGroups = [unreadMessages allGroups];
|
||||||
for (NSString *groupID in allGroups) {
|
for (NSString *groupID in allGroups) {
|
||||||
TSThread *thread = [TSThread fetchObjectWithUniqueID:groupID transaction:transaction];
|
TSGroupThread *thread = [TSGroupThread fetchObjectWithUniqueID:groupID transaction:transaction];
|
||||||
if (thread.isMuted) continue;
|
if (thread.isMuted) continue;
|
||||||
[unreadMessages enumerateKeysAndObjectsInGroup:groupID
|
[unreadMessages enumerateKeysAndObjectsInGroup:groupID
|
||||||
usingBlock:^(NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) {
|
usingBlock:^(NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) {
|
||||||
|
@ -85,6 +85,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
NSLog(@"Found an already read message in the * unread * messages list.");
|
NSLog(@"Found an already read message in the * unread * messages list.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
TSIncomingMessage * incomingMessage = (TSIncomingMessage *)object;
|
||||||
|
if (incomingMessage != nil && thread.isOnlyNotifyingForMentions && !incomingMessage.isUserMentioned) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
count += 1;
|
count += 1;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue