2
2
mirror of https://github.com/mastodon/mastodon-ios synced 2025-04-11 22:58:02 +02:00

Implement quiet public as a default post visibility option

Update code to handle the additional .unlisted post visibility option. And make sure to fetch full account info, which includes any custom privacy settings.

Fixes  #1395 [BUG] Implement Quit Public post privacy like the Android app
This commit is contained in:
shannon 2025-02-12 10:44:41 -05:00
parent 87522825f5
commit 44ac523f33
7 changed files with 12 additions and 24 deletions

View File

@ -873,10 +873,7 @@
"custom": "Custom"
},
"default_post_visibility": {
"title": "Default Post Visibility",
"public": "Public",
"followers_only": "Followers Only",
"only_people_mentioned": "Only People Mentioned"
"title": "Default Post Visibility"
},
"manually_approve_follow_requests": "Manually Approve Follow Requests",
"show_followers_and_following": "Show Followers & Following",

View File

@ -25,13 +25,13 @@ class PrivacySafetyViewModel: ObservableObject, PrivacySafetySettingApplicable {
var title: String {
switch self {
case .public:
return L10n.Scene.Settings.PrivacySafety.DefaultPostVisibility.public
return L10n.Scene.Compose.Visibility.public
case .unlisted:
return L10n.Scene.Settings.PrivacySafety.DefaultPostVisibility.unlisted
return L10n.Scene.Compose.Visibility.unlisted
case .followersOnly:
return L10n.Scene.Settings.PrivacySafety.DefaultPostVisibility.followersOnly
return L10n.Scene.Compose.Visibility.private
case .onlyPeopleMentioned:
return L10n.Scene.Settings.PrivacySafety.DefaultPostVisibility.onlyPeopleMentioned
return L10n.Scene.Compose.Visibility.direct
}
}

View File

@ -14,12 +14,7 @@ import MastodonSDK
extension APIService {
public func accountInfo(_ authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Entity.Account {
let account = try await Mastodon.API.Account.accountInfo(
session: session,
domain: authenticationBox.domain,
userID: authenticationBox.userID,
authorization: authenticationBox.userAuthorization
).singleOutput().value
let account = try await Mastodon.API.Account.verifyCredentials(session: session, domain: authenticationBox.domain, authorization: authenticationBox.userAuthorization)
PersistenceManager.shared.cacheAccount(account, forUserID: authenticationBox.authentication.userIdentifier())

View File

@ -1717,12 +1717,6 @@ public enum L10n {
/// Privacy & Safety
public static let title = L10n.tr("Localizable", "Scene.Settings.PrivacySafety.Title", fallback: "Privacy & Safety")
public enum DefaultPostVisibility {
/// Followers Only
public static let followersOnly = L10n.tr("Localizable", "Scene.Settings.PrivacySafety.DefaultPostVisibility.FollowersOnly", fallback: "Followers Only")
/// Only People Mentioned
public static let onlyPeopleMentioned = L10n.tr("Localizable", "Scene.Settings.PrivacySafety.DefaultPostVisibility.OnlyPeopleMentioned", fallback: "Only People Mentioned")
/// Public
public static let `public` = L10n.tr("Localizable", "Scene.Settings.PrivacySafety.DefaultPostVisibility.Public", fallback: "Public")
/// Default Post Visibility
public static let title = L10n.tr("Localizable", "Scene.Settings.PrivacySafety.DefaultPostVisibility.Title", fallback: "Default Post Visibility")
}

View File

@ -598,9 +598,6 @@ If you disagree with the policy for **%@**, you can go back and pick a different
"Scene.Settings.Overview.SupportMastodon" = "Donate to Mastodon";
"Scene.Settings.Overview.Title" = "Settings";
"Scene.Settings.PrivacySafety.AppearInSearchEngines" = "Appear in Search Engines";
"Scene.Settings.PrivacySafety.DefaultPostVisibility.FollowersOnly" = "Followers Only";
"Scene.Settings.PrivacySafety.DefaultPostVisibility.OnlyPeopleMentioned" = "Only People Mentioned";
"Scene.Settings.PrivacySafety.DefaultPostVisibility.Public" = "Public";
"Scene.Settings.PrivacySafety.DefaultPostVisibility.Title" = "Default Post Visibility";
"Scene.Settings.PrivacySafety.ManuallyApproveFollowRequests" = "Manually Approve Follow Requests";
"Scene.Settings.PrivacySafety.Preset.Custom" = "Custom";

View File

@ -362,6 +362,7 @@ extension ComposeContentViewController {
viewModel.$recentLanguages.assign(to: &composeContentToolbarViewModel.$recentLanguages)
// bind back to source due to visibility not update via delegate
composeContentToolbarViewModel.visibility = viewModel.visibility
composeContentToolbarViewModel.$visibility
.dropFirst()
.receive(on: DispatchQueue.main)

View File

@ -156,7 +156,11 @@ public final class ComposeContentViewModel: NSObject, ObservableObject {
guard let author = authenticationBox.cachedAccount else {
return .public
}
return author.locked ? .private : .public
if let defaultPrivacy = author.source?.privacy, let statusPrivacy = Mastodon.Entity.Status.Visibility(rawValue: defaultPrivacy.rawValue) {
return statusPrivacy
} else {
return author.locked ? .private : .public
}
}()
// set visibility for reply post
if case .reply(let record) = destination {