diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 54451899d571..985b41e8d298 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,5 +1,6 @@ 18.6 ----- +* [**] Comments: Users can now follow conversation via notifications, in addition to emails. [#17363] * [**] Block editor: Block inserter indicates newly available block types [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4047] diff --git a/WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift b/WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift index 7eb571d5780a..946e99188438 100644 --- a/WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift +++ b/WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift @@ -61,7 +61,7 @@ enum FeatureFlag: Int, CaseIterable, OverrideableFlag { case .domains: return BuildConfiguration.current == .localDeveloper case .followConversationViaNotifications: - return false + return true } } diff --git a/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.m b/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.m index 5c1e426b1122..dab13e89b6d9 100644 --- a/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.m +++ b/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.m @@ -1401,34 +1401,31 @@ - (void)handleFollowConversationButtonTapped - (void)handleNotificationsButtonTappedWithUndo:(BOOL)canUndo completion:(void (^ _Nullable)(BOOL))completion { BOOL desiredState = !self.post.receivesCommentNotifications; - - NSString *successTitle = desiredState - ? NSLocalizedString(@"In-app notifications enabled", @"The app successfully enabled notifications for the subscription") - : NSLocalizedString(@"In-app notifications disabled", @"The app successfully disabled notifications for the subscription"); - - NSString *failureTitle = desiredState - ? NSLocalizedString(@"Could not enable notifications", @"The app failed to enable notifications for the subscription") - : NSLocalizedString(@"Could not disable notifications", @"The app failed to disable notifications for the subscription"); + PostSubscriptionAction action = desiredState ? PostSubscriptionActionEnableNotification : PostSubscriptionActionDisableNotification; __weak __typeof(self) weakSelf = self; + NSString* (^noticeTitle)(BOOL) = ^NSString* (BOOL success) { + return [weakSelf noticeTitleForAction:action success:success]; + }; + [self.followCommentsService toggleNotificationSettings:desiredState success:^{ if (completion) { completion(YES); } if (!canUndo) { - [weakSelf displayNoticeWithTitle:successTitle message:nil]; + [weakSelf displayNoticeWithTitle:noticeTitle(YES) message:nil]; return; } // show the undo notice with action button. NSString *undoActionTitle = NSLocalizedString(@"Undo", @"Button title. Reverts the previous notification operation"); - [weakSelf displayActionableNoticeWithTitle:successTitle message:nil actionTitle:undoActionTitle actionHandler:^(BOOL accepted) { + [weakSelf displayActionableNoticeWithTitle:noticeTitle(YES) message:nil actionTitle:undoActionTitle actionHandler:^(BOOL accepted) { [weakSelf handleNotificationsButtonTappedWithUndo:NO completion:nil]; }]; } failure:^(NSError * _Nullable error) { - [weakSelf displayNoticeWithTitle:failureTitle message:nil]; + [weakSelf displayNoticeWithTitle:noticeTitle(NO) message:nil]; if (completion) { completion(NO); } diff --git a/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.swift b/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.swift index ba4ab35a0d13..371e7bba41e9 100644 --- a/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.swift +++ b/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.swift @@ -11,4 +11,26 @@ import Foundation let bottomSheet = BottomSheetViewController(childViewController: sheetViewController) bottomSheet.show(from: self, sourceBarButtonItem: sourceBarButtonItem) } + + // MARK: Post Subscriptions + + /// Enumerates the kind of actions available in relation to post subscriptions. + /// TODO: Add `followConversation` and `unfollowConversation` once the "Follow Conversation" feature flag is removed. + @objc enum PostSubscriptionAction: Int { + case enableNotification + case disableNotification + } + + func noticeTitle(forAction action: PostSubscriptionAction, success: Bool) -> String { + switch (action, success) { + case (.enableNotification, true): + return NSLocalizedString("In-app notifications enabled", comment: "The app successfully enabled notifications for the subscription") + case (.enableNotification, false): + return NSLocalizedString("Could not enable notifications", comment: "The app failed to enable notifications for the subscription") + case (.disableNotification, true): + return NSLocalizedString("In-app notifications disabled", comment: "The app successfully disabled notifications for the subscription") + case (.disableNotification, false): + return NSLocalizedString("Could not disable notifications", comment: "The app failed to disable notifications for the subscription") + } + } }