forked from shadowfacts/Tusker
Add preference for how reply CWs are copied
This commit is contained in:
parent
9dfaa9e023
commit
51a03553a9
|
@ -169,6 +169,7 @@
|
||||||
D6D4DDF0212518A200E1C4BB /* TuskerUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D4DDEF212518A200E1C4BB /* TuskerUITests.swift */; };
|
D6D4DDF0212518A200E1C4BB /* TuskerUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D4DDEF212518A200E1C4BB /* TuskerUITests.swift */; };
|
||||||
D6D58DF922074B74009C8DD9 /* LinkLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D58DF822074B74009C8DD9 /* LinkLabel.swift */; };
|
D6D58DF922074B74009C8DD9 /* LinkLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D58DF822074B74009C8DD9 /* LinkLabel.swift */; };
|
||||||
D6DD353B22F25D2E00A9563A /* TimelineSegment.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD353A22F25D2E00A9563A /* TimelineSegment.swift */; };
|
D6DD353B22F25D2E00A9563A /* TimelineSegment.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD353A22F25D2E00A9563A /* TimelineSegment.swift */; };
|
||||||
|
D6DD353D22F28CD000A9563A /* ContentWarningCopyMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD353C22F28CD000A9563A /* ContentWarningCopyMode.swift */; };
|
||||||
D6E0DC8E216EDF1E00369478 /* Previewing.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6E0DC8D216EDF1E00369478 /* Previewing.swift */; };
|
D6E0DC8E216EDF1E00369478 /* Previewing.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6E0DC8D216EDF1E00369478 /* Previewing.swift */; };
|
||||||
D6E6F26321603F8B006A8599 /* CharacterCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6E6F26221603F8B006A8599 /* CharacterCounter.swift */; };
|
D6E6F26321603F8B006A8599 /* CharacterCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6E6F26221603F8B006A8599 /* CharacterCounter.swift */; };
|
||||||
D6E6F26521604242006A8599 /* CharacterCounterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6E6F26421604242006A8599 /* CharacterCounterTests.swift */; };
|
D6E6F26521604242006A8599 /* CharacterCounterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6E6F26421604242006A8599 /* CharacterCounterTests.swift */; };
|
||||||
|
@ -407,6 +408,7 @@
|
||||||
D6D4DDF1212518A200E1C4BB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
D6D4DDF1212518A200E1C4BB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
D6D58DF822074B74009C8DD9 /* LinkLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkLabel.swift; sourceTree = "<group>"; };
|
D6D58DF822074B74009C8DD9 /* LinkLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkLabel.swift; sourceTree = "<group>"; };
|
||||||
D6DD353A22F25D2E00A9563A /* TimelineSegment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = TimelineSegment.swift; path = ../../../../../../System/Volumes/Data/Users/shadowfacts/Dev/iOS/Tusker/Pachyderm/TimelineSegment.swift; sourceTree = "<group>"; };
|
D6DD353A22F25D2E00A9563A /* TimelineSegment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = TimelineSegment.swift; path = ../../../../../../System/Volumes/Data/Users/shadowfacts/Dev/iOS/Tusker/Pachyderm/TimelineSegment.swift; sourceTree = "<group>"; };
|
||||||
|
D6DD353C22F28CD000A9563A /* ContentWarningCopyMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ContentWarningCopyMode.swift; path = ../../../../../../../System/Volumes/Data/Users/shadowfacts/Dev/iOS/Tusker/Tusker/Preferences/ContentWarningCopyMode.swift; sourceTree = "<group>"; };
|
||||||
D6E0DC8D216EDF1E00369478 /* Previewing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Previewing.swift; sourceTree = "<group>"; };
|
D6E0DC8D216EDF1E00369478 /* Previewing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Previewing.swift; sourceTree = "<group>"; };
|
||||||
D6E6F26221603F8B006A8599 /* CharacterCounter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CharacterCounter.swift; sourceTree = "<group>"; };
|
D6E6F26221603F8B006A8599 /* CharacterCounter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CharacterCounter.swift; sourceTree = "<group>"; };
|
||||||
D6E6F26421604242006A8599 /* CharacterCounterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CharacterCounterTests.swift; sourceTree = "<group>"; };
|
D6E6F26421604242006A8599 /* CharacterCounterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CharacterCounterTests.swift; sourceTree = "<group>"; };
|
||||||
|
@ -802,6 +804,7 @@
|
||||||
D663626321360D2300C9CBA2 /* AvatarStyle.swift */,
|
D663626321360D2300C9CBA2 /* AvatarStyle.swift */,
|
||||||
D66362692136163000C9CBA2 /* PreferencesAdaptive.swift */,
|
D66362692136163000C9CBA2 /* PreferencesAdaptive.swift */,
|
||||||
0427033522B30B3D000D31B6 /* Preference.swift */,
|
0427033522B30B3D000D31B6 /* Preference.swift */,
|
||||||
|
D6DD353C22F28CD000A9563A /* ContentWarningCopyMode.swift */,
|
||||||
);
|
);
|
||||||
path = Preferences;
|
path = Preferences;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -1396,6 +1399,7 @@
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
D6285B5321EA708700FE4B39 /* StatusFormat.swift in Sources */,
|
D6285B5321EA708700FE4B39 /* StatusFormat.swift in Sources */,
|
||||||
|
D6DD353D22F28CD000A9563A /* ContentWarningCopyMode.swift in Sources */,
|
||||||
0427033A22B31269000D31B6 /* AdvancedPrefsView.swift in Sources */,
|
0427033A22B31269000D31B6 /* AdvancedPrefsView.swift in Sources */,
|
||||||
D6757A822157E8FA00721E32 /* XCBSession.swift in Sources */,
|
D6757A822157E8FA00721E32 /* XCBSession.swift in Sources */,
|
||||||
04DACE8C212CB14B009840C4 /* MainTabBarViewController.swift in Sources */,
|
04DACE8C212CB14B009840C4 /* MainTabBarViewController.swift in Sources */,
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
//
|
||||||
|
// ContentWarningCopyMode.swift
|
||||||
|
// Tusker
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 7/31/19.
|
||||||
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
enum ContentWarningCopyMode: String, Codable {
|
||||||
|
case asIs // copy CW as-is
|
||||||
|
case prependRe // prepend 're: ' to the beginning of the CW, if it doesn't already have it
|
||||||
|
case doNotCopy // don't copy CW at all
|
||||||
|
}
|
|
@ -46,6 +46,7 @@ class Preferences: Codable, BindableObject {
|
||||||
// MARK: - Behavior
|
// MARK: - Behavior
|
||||||
var defaultPostVisibility = Status.Visibility.public { willSet { willChange.send(self) } }
|
var defaultPostVisibility = Status.Visibility.public { willSet { willChange.send(self) } }
|
||||||
var automaticallySaveDrafts = true { willSet { willChange.send(self) } }
|
var automaticallySaveDrafts = true { willSet { willChange.send(self) } }
|
||||||
|
var contentWarningCopyMode = ContentWarningCopyMode.asIs { willSet { willChange.send(self) } }
|
||||||
var openLinksInApps = true { willSet { willChange.send(self) } }
|
var openLinksInApps = true { willSet { willChange.send(self) } }
|
||||||
|
|
||||||
// MARK: - Advanced
|
// MARK: - Advanced
|
||||||
|
|
|
@ -127,9 +127,19 @@ class ComposeViewController: UIViewController {
|
||||||
|
|
||||||
if let inReplyToID = inReplyToID, let inReplyTo = MastodonCache.status(for: inReplyToID) {
|
if let inReplyToID = inReplyToID, let inReplyTo = MastodonCache.status(for: inReplyToID) {
|
||||||
visibility = inReplyTo.visibility
|
visibility = inReplyTo.visibility
|
||||||
contentWarningEnabled = !inReplyTo.spoilerText.isEmpty
|
if Preferences.shared.contentWarningCopyMode == .doNotCopy {
|
||||||
contentWarningContainerView.isHidden = !contentWarningEnabled
|
contentWarningEnabled = false
|
||||||
contentWarningTextField.text = inReplyTo.spoilerText
|
contentWarningContainerView.isHidden = true
|
||||||
|
} else {
|
||||||
|
contentWarningEnabled = !inReplyTo.spoilerText.isEmpty
|
||||||
|
contentWarningContainerView.isHidden = !contentWarningEnabled
|
||||||
|
if Preferences.shared.contentWarningCopyMode == .prependRe,
|
||||||
|
!inReplyTo.spoilerText.lowercased().starts(with: "re:") {
|
||||||
|
contentWarningTextField.text = "re: \(inReplyTo.spoilerText)"
|
||||||
|
} else {
|
||||||
|
contentWarningTextField.text = inReplyTo.spoilerText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let replyView = ComposeStatusReplyView.create()
|
let replyView = ComposeStatusReplyView.create()
|
||||||
replyView.updateUI(for: inReplyTo)
|
replyView.updateUI(for: inReplyTo)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import Pachyderm
|
||||||
struct BehaviorPrefsView : View {
|
struct BehaviorPrefsView : View {
|
||||||
@Preference(\.defaultPostVisibility) var defaultPostVisibility: Status.Visibility
|
@Preference(\.defaultPostVisibility) var defaultPostVisibility: Status.Visibility
|
||||||
@Preference(\.automaticallySaveDrafts) var automaticallySaveDrafts: Bool
|
@Preference(\.automaticallySaveDrafts) var automaticallySaveDrafts: Bool
|
||||||
|
@Preference(\.contentWarningCopyMode) var contentWarningCopyMode: ContentWarningCopyMode
|
||||||
@Preference(\.openLinksInApps) var openLinksInApps: Bool
|
@Preference(\.openLinksInApps) var openLinksInApps: Bool
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
@ -36,6 +37,11 @@ struct BehaviorPrefsView : View {
|
||||||
Toggle(isOn: _automaticallySaveDrafts.binding) {
|
Toggle(isOn: _automaticallySaveDrafts.binding) {
|
||||||
Text("Automatically Save Drafts")
|
Text("Automatically Save Drafts")
|
||||||
}
|
}
|
||||||
|
Picker(selection: _contentWarningCopyMode.binding, label: Text("Content Warning Copy Style")) {
|
||||||
|
Text("As-is").tag(ContentWarningCopyMode.asIs)
|
||||||
|
Text("Prepend 're: '").tag(ContentWarningCopyMode.prependRe)
|
||||||
|
Text("Don't copy").tag(ContentWarningCopyMode.doNotCopy)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue