diff --git a/Mastodon/Protocol/Provider/DataSourceFacade+Status.swift b/Mastodon/Protocol/Provider/DataSourceFacade+Status.swift index ff41cc126..332ed75e4 100644 --- a/Mastodon/Protocol/Provider/DataSourceFacade+Status.swift +++ b/Mastodon/Protocol/Provider/DataSourceFacade+Status.swift @@ -205,42 +205,45 @@ extension DataSourceFacade { menuContext: MenuContext ) async throws { switch action { - case .hideReblogs(let actionContext): - //FIXME: Add localized strings - let alertController = UIAlertController( - title: actionContext.showReblogs ? "Really hide?" : "Really show?", - message: actionContext.showReblogs ? "Really??" : "Really??", - preferredStyle: .alert - ) + case .hideReblogs(let actionContext): + let title = actionContext.showReblogs ? L10n.Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.title : L10n.Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.title + let message = actionContext.showReblogs ? L10n.Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.message : L10n.Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.message - let showHideReblogsAction = UIAlertAction( - title: actionContext.showReblogs ? "Show" : "Hide", - style: .default - ) { [weak dependency] _ in - guard let dependency else { return } + let alertController = UIAlertController( + title: title, + message: message, + preferredStyle: .alert + ) - Task { - let managedObjectContext = dependency.context.managedObjectContext - let _user: ManagedObjectRecord? = try? await managedObjectContext.perform { - guard let user = menuContext.author?.object(in: managedObjectContext) else { return nil } - return ManagedObjectRecord(objectID: user.objectID) - } + let actionTitle = actionContext.showReblogs ? L10n.Common.Controls.Friendship.hideReblogs : L10n.Common.Controls.Friendship.showReblogs + let showHideReblogsAction = UIAlertAction( + title: actionTitle, + style: .destructive + ) { [weak dependency] _ in + guard let dependency else { return } - guard let user = _user else { return } + Task { + let managedObjectContext = dependency.context.managedObjectContext + let _user: ManagedObjectRecord? = try? await managedObjectContext.perform { + guard let user = menuContext.author?.object(in: managedObjectContext) else { return nil } + return ManagedObjectRecord(objectID: user.objectID) + } - try await DataSourceFacade.responseToShowHideReblogAction( - dependency: dependency, - user: user - ) - } - } + guard let user = _user else { return } - alertController.addAction(showHideReblogsAction) + try await DataSourceFacade.responseToShowHideReblogAction( + dependency: dependency, + user: user + ) + } + } - let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) - alertController.addAction(cancelAction) + alertController.addAction(showHideReblogsAction) - dependency.present(alertController, animated: true) + let cancelAction = UIAlertAction(title: L10n.Common.Controls.Actions.cancel, style: .cancel) + alertController.addAction(cancelAction) + + dependency.present(alertController, animated: true) case .muteUser(let actionContext): let alertController = UIAlertController( title: actionContext.isMuting ? L10n.Scene.Profile.RelationshipActionAlert.ConfirmUnmuteUser.title : L10n.Scene.Profile.RelationshipActionAlert.ConfirmMuteUser.title, diff --git a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift index 1d5b9895b..52ed59c09 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift +++ b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift @@ -713,6 +713,12 @@ public enum L10n { /// Block Account public static let title = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmBlockUser.Title") } + public enum ConfirmHideReblogs { + /// Confirm to hide reblogs + public static let message = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Message") + /// Hide reblogs + public static let title = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Title") + } public enum ConfirmMuteUser { /// Confirm to mute %@ public static func message(_ p1: Any) -> String { @@ -721,6 +727,12 @@ public enum L10n { /// Mute Account public static let title = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmMuteUser.Title") } + public enum ConfirmShowReblogs { + /// Confirm to show reblogs + public static let message = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Message") + /// Show Reblogs + public static let title = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Title") + } public enum ConfirmUnblockUser { /// Confirm to unblock %@ public static func message(_ p1: Any) -> String { diff --git a/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings b/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings index 94bee697c..6917eb0c7 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings +++ b/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings @@ -79,6 +79,7 @@ Please check your internet connection."; "Common.Controls.Friendship.UnmuteUser" = "Unmute %@"; "Common.Controls.Friendship.HideReblogs" = "Hide Reblogs"; "Common.Controls.Friendship.ShowReblogs" = "Show Reblogs"; + "Common.Controls.Keyboard.Common.ComposeNewPost" = "Compose New Post"; "Common.Controls.Keyboard.Common.OpenSettings" = "Open Settings"; "Common.Controls.Keyboard.Common.ShowFavorites" = "Show Favorites"; @@ -264,6 +265,10 @@ uploaded to Mastodon."; "Scene.Profile.RelationshipActionAlert.ConfirmUnblockUser.Title" = "Unblock Account"; "Scene.Profile.RelationshipActionAlert.ConfirmUnmuteUser.Message" = "Confirm to unmute %@"; "Scene.Profile.RelationshipActionAlert.ConfirmUnmuteUser.Title" = "Unmute Account"; +"Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Message" = "Confirm to show reblogs"; +"Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Title" = "Show Reblogs"; +"Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Message" = "Confirm to hide reblogs"; +"Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Title" = "Hide reblogs"; "Scene.Profile.SegmentedControl.About" = "About"; "Scene.Profile.SegmentedControl.Media" = "Media"; "Scene.Profile.SegmentedControl.Posts" = "Posts"; diff --git a/MastodonSDK/Sources/MastodonUI/View/Menu/MastodonMenu.swift b/MastodonSDK/Sources/MastodonUI/View/Menu/MastodonMenu.swift index b85e71138..422494328 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Menu/MastodonMenu.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Menu/MastodonMenu.swift @@ -52,7 +52,7 @@ extension MastodonMenu { func build(delegate: MastodonMenuDelegate) -> BuiltAction { switch self { case .hideReblogs(let context): - let title = context.showReblogs ? L10n.Common.Controls.Friendship.hideReblogs : L10n.Common.Controls.Friendship.hideReblogs + let title = context.showReblogs ? L10n.Common.Controls.Friendship.hideReblogs : L10n.Common.Controls.Friendship.showReblogs let reblogAction = BuiltAction( title: title, image: UIImage(systemName: "arrow.2.squarepath")