From c7f3bac3305caedd99a60f4994b069fd29e51db8 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 1 Nov 2022 22:43:02 -0400 Subject: [PATCH] Add sterner warning about post content type --- Tusker/API/InstanceFeatures.swift | 4 ++++ Tusker/Screens/Preferences/AdvancedPrefsView.swift | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Tusker/API/InstanceFeatures.swift b/Tusker/API/InstanceFeatures.swift index df18022b09..6e0507c68c 100644 --- a/Tusker/API/InstanceFeatures.swift +++ b/Tusker/API/InstanceFeatures.swift @@ -50,6 +50,10 @@ struct InstanceFeatures { || (instanceType == .pleroma && hasVersion(2, 0, 0)) } + var probablySupportsMarkdown: Bool { + instanceType == .pleroma || instanceType == .glitch || instanceType == .hometown + } + mutating func update(instance: Instance, nodeInfo: NodeInfo?) { let ver = instance.version.lowercased() if ver.contains("glitch") { diff --git a/Tusker/Screens/Preferences/AdvancedPrefsView.swift b/Tusker/Screens/Preferences/AdvancedPrefsView.swift index 6a68980d9b..4fc68ca166 100644 --- a/Tusker/Screens/Preferences/AdvancedPrefsView.swift +++ b/Tusker/Screens/Preferences/AdvancedPrefsView.swift @@ -23,7 +23,17 @@ struct AdvancedPrefsView : View { } var formattingFooter: some View { - Text("This option is only supported for Pleroma and Mastodon instances with formatting enabled. On all other instances, formatting symbols will remain in the unformatted plain text.").lineLimit(nil) + var s: AttributedString = "This option is only supported with Pleroma and some compatible Mastodon instances (such as Glitch or Hometown).\n" + if let account = LocalData.shared.getMostRecentAccount() { + let mastodonController = MastodonController.getForAccount(account) + // shouldn't need to load the instance here, because loading it is kicked off my the scene delegate + if !mastodonController.instanceFeatures.probablySupportsMarkdown { + var warning = AttributedString("\(account.instanceURL.host!) does not appear to support formatting. Using formatting symbols may not have an effect.") + warning[AttributeScopes.SwiftUIAttributes.FontAttribute.self] = .caption.bold() + s += warning + } + } + return Text(s).lineLimit(nil) } var formattingSection: some View {