From b0e03f5dfd9ca71c0da4abf302882d3179d2f0e8 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Mon, 26 Jul 2021 16:16:14 +1000 Subject: [PATCH] update subtitle status in conversation screen instantly --- .../Settings/OWSConversationSettingsViewController.m | 6 ++---- SessionMessagingKit/Threads/TSGroupThread.h | 1 + SessionMessagingKit/Threads/TSGroupThread.m | 11 +++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Session/Conversations/Settings/OWSConversationSettingsViewController.m b/Session/Conversations/Settings/OWSConversationSettingsViewController.m index 16f4fc84f..0e27958f8 100644 --- a/Session/Conversations/Settings/OWSConversationSettingsViewController.m +++ b/Session/Conversations/Settings/OWSConversationSettingsViewController.m @@ -1001,13 +1001,11 @@ CGFloat kIconViewLength = 24; UISwitch *uiSwitch = (UISwitch *)sender; if (uiSwitch.isOn) { [LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { - ((TSGroupThread *)self.thread).isOnlyNotifyMentions = true; - [self.thread saveWithTransaction:transaction]; + [(TSGroupThread *)self.thread setIsOnlyNotifyMentions:true withTransaction:transaction]; }]; } else { [LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { - ((TSGroupThread *)self.thread).isOnlyNotifyMentions = false; - [self.thread saveWithTransaction:transaction]; + [(TSGroupThread *)self.thread setIsOnlyNotifyMentions:false withTransaction:transaction]; }]; } } diff --git a/SessionMessagingKit/Threads/TSGroupThread.h b/SessionMessagingKit/Threads/TSGroupThread.h index 297ab5504..aa55f60f7 100644 --- a/SessionMessagingKit/Threads/TSGroupThread.h +++ b/SessionMessagingKit/Threads/TSGroupThread.h @@ -45,6 +45,7 @@ extern NSString *const TSGroupThread_NotificationKey_UniqueId; transaction:(YapDatabaseReadWriteTransaction *)transaction; - (void)setGroupModel:(TSGroupModel *)newGroupModel withTransaction:(YapDatabaseReadWriteTransaction *)transaction; +- (void)setIsOnlyNotifyMentions:(BOOL)isOnlyNotifyMentions withTransaction:(YapDatabaseReadWriteTransaction *)transaction; - (void)leaveGroupWithSneakyTransaction; - (void)leaveGroupWithTransaction:(YapDatabaseReadWriteTransaction *)transaction; diff --git a/SessionMessagingKit/Threads/TSGroupThread.m b/SessionMessagingKit/Threads/TSGroupThread.m index 542a2bb4e..e0a94401b 100644 --- a/SessionMessagingKit/Threads/TSGroupThread.m +++ b/SessionMessagingKit/Threads/TSGroupThread.m @@ -208,6 +208,17 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific }]; } +- (void)setIsOnlyNotifyMentions:(BOOL)isOnlyNotifyMentions withTransaction:(YapDatabaseReadWriteTransaction *)transaction +{ + self.isOnlyNotifyMentions = isOnlyNotifyMentions; + + [self saveWithTransaction:transaction]; + + [transaction addCompletionQueue:dispatch_get_main_queue() completionBlock:^{ + [NSNotificationCenter.defaultCenter postNotificationName:NSNotification.groupThreadUpdated object:self.uniqueId]; + }]; +} + - (void)leaveGroupWithSneakyTransaction { [LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {