From 27476ff1f35a41f2a77c055a7171587ed551e829 Mon Sep 17 00:00:00 2001 From: David Christiandy <1299411+dvdchr@users.noreply.github.com> Date: Mon, 25 Oct 2021 23:44:03 +0700 Subject: [PATCH 1/4] Refactor strings related to post subscription notifications --- .../Reader/ReaderCommentsViewController.m | 19 +++++++--------- .../Reader/ReaderCommentsViewController.swift | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+), 11 deletions(-) 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") + } + } } From 426f7e1bea2dcab1939e59cdb787fe935ed0e904 Mon Sep 17 00:00:00 2001 From: David Christiandy <1299411+dvdchr@users.noreply.github.com> Date: Mon, 25 Oct 2021 23:44:57 +0700 Subject: [PATCH 2/4] Enable follow conversation flag --- WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 } } From 92970e2ec1654794805150a7eeafbfb5a08846e2 Mon Sep 17 00:00:00 2001 From: David Christiandy <1299411+dvdchr@users.noreply.github.com> Date: Tue, 26 Oct 2021 00:09:49 +0700 Subject: [PATCH 3/4] Update release notes --- RELEASE-NOTES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 3b33c5b4d5bd..659d74c2ada5 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,6 +1,6 @@ 18.6 ----- - +* [*] Comments: Users can now follow conversation via notifications, in addition to emails. [#17363] 18.5 ----- From c1bbaf642c57fb53d2de86f372e776e439c37a11 Mon Sep 17 00:00:00 2001 From: David Christiandy <1299411+dvdchr@users.noreply.github.com> Date: Tue, 26 Oct 2021 19:09:02 +0700 Subject: [PATCH 4/4] Update release notes --- RELEASE-NOTES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 659d74c2ada5..ba4475e88d99 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,6 +1,6 @@ 18.6 ----- -* [*] Comments: Users can now follow conversation via notifications, in addition to emails. [#17363] +* [**] Comments: Users can now follow conversation via notifications, in addition to emails. [#17363] 18.5 -----