Use server preference for local-only on Hometown

Closes #281
This commit is contained in:
Shadowfacts 2023-10-27 15:12:48 -05:00
parent 6e5e0c3bb5
commit eb496243c7
5 changed files with 9 additions and 3 deletions

View File

@ -11,6 +11,8 @@ public struct Preferences: Codable, Sendable {
public let postingDefaultVisibility: Visibility
public let postingDefaultSensitive: Bool
public let postingDefaultLanguage: String
// Whether posts federate or not (local-only) on Hometown
public let postingDefaultFederation: Bool?
public let readingExpandMedia: ExpandMedia
public let readingExpandSpoilers: Bool
public let readingAutoplayGifs: Bool
@ -19,6 +21,7 @@ public struct Preferences: Codable, Sendable {
case postingDefaultVisibility = "posting:default:visibility"
case postingDefaultSensitive = "posting:default:sensitive"
case postingDefaultLanguage = "posting:default:language"
case postingDefaultFederation = "posting:default:federation"
case readingExpandMedia = "reading:expand:media"
case readingExpandSpoilers = "reading:expand:spoilers"
case readingAutoplayGifs = "reading:autoplay:gifs"

View File

@ -64,7 +64,7 @@ class ShareViewController: UIViewController {
inReplyToID: nil,
visibility: visibility,
language: serverPrefs?.postingDefaultLanguage,
localOnly: false
localOnly: !(serverPrefs?.postingDefaultFederation ?? true)
)
for attachment in await attachments {

View File

@ -370,6 +370,7 @@ class MastodonController: ObservableObject {
}
accountPreferences!.serverDefaultLanguage = prefs.postingDefaultLanguage
accountPreferences!.serverDefaultVisibility = prefs.postingDefaultVisibility
accountPreferences!.serverDefaultFederation = prefs.postingDefaultFederation ?? true
}
private func updateActiveInstance(from instance: Instance) {
@ -538,7 +539,7 @@ class MastodonController: ObservableObject {
} else {
Preferences.shared.defaultPostVisibility.resolved(withServerDefault: accountPreferences!.serverDefaultVisibility)
}
var localOnly = false
var localOnly = instanceFeatures.localOnlyPosts && !accountPreferences!.serverDefaultFederation
var contentWarning = ""
if let inReplyToID = inReplyToID,

View File

@ -24,6 +24,7 @@ public final class AccountPreferences: NSManagedObject {
@NSManaged public var accountID: String
@NSManaged var createdAt: Date
@NSManaged var pinnedTimelinesData: Data?
@NSManaged var serverDefaultFederation: Bool
@NSManaged var serverDefaultLanguage: String?
@NSManaged private var serverDefaultVisibilityString: String?

View File

@ -33,6 +33,7 @@
<attribute name="accountID" optional="YES" attributeType="String"/>
<attribute name="createdAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="pinnedTimelinesData" optional="YES" attributeType="Binary"/>
<attribute name="serverDefaultFederation" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/>
<attribute name="serverDefaultLanguage" optional="YES" attributeType="String"/>
<attribute name="serverDefaultVisibilityString" optional="YES" attributeType="String"/>
</entity>
@ -157,4 +158,4 @@
<memberEntity name="Account"/>
<memberEntity name="ActiveInstance"/>
</configuration>
</model>
</model>