Disable translations in DMs by default
There is an option to enable it now. Changelog-Changed: Disable translations in DMs by default
This commit is contained in:
@@ -163,6 +163,12 @@ class UserSettingsStore: ObservableObject {
|
|||||||
UserDefaults.standard.set(notification_only_from_following, forKey: "notification_only_from_following")
|
UserDefaults.standard.set(notification_only_from_following, forKey: "notification_only_from_following")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Published var translate_dms: Bool {
|
||||||
|
didSet {
|
||||||
|
UserDefaults.standard.set(translate_dms, forKey: "translate_dms")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Published var truncate_timeline_text: Bool {
|
@Published var truncate_timeline_text: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
@@ -275,6 +281,7 @@ class UserSettingsStore: ObservableObject {
|
|||||||
like_notification = UserDefaults.standard.object(forKey: "like_notification") as? Bool ?? true
|
like_notification = UserDefaults.standard.object(forKey: "like_notification") as? Bool ?? true
|
||||||
dm_notification = UserDefaults.standard.object(forKey: "dm_notification") as? Bool ?? true
|
dm_notification = UserDefaults.standard.object(forKey: "dm_notification") as? Bool ?? true
|
||||||
notification_only_from_following = UserDefaults.standard.object(forKey: "notification_only_from_following") as? Bool ?? false
|
notification_only_from_following = UserDefaults.standard.object(forKey: "notification_only_from_following") as? Bool ?? false
|
||||||
|
translate_dms = UserDefaults.standard.object(forKey: "translate_dms") as? Bool ?? false
|
||||||
truncate_timeline_text = UserDefaults.standard.object(forKey: "truncate_timeline_text") as? Bool ?? false
|
truncate_timeline_text = UserDefaults.standard.object(forKey: "truncate_timeline_text") as? Bool ?? false
|
||||||
truncate_mention_text = UserDefaults.standard.object(forKey: "truncate_mention_text") as? Bool ?? false
|
truncate_mention_text = UserDefaults.standard.object(forKey: "truncate_mention_text") as? Bool ?? false
|
||||||
disable_animation = should_disable_image_animation()
|
disable_animation = should_disable_image_animation()
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ struct DMView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dm_options: EventViewOptions {
|
||||||
|
if self.damus_state.settings.translate_dms {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return [.no_translate]
|
||||||
|
}
|
||||||
|
|
||||||
var DM: some View {
|
var DM: some View {
|
||||||
HStack {
|
HStack {
|
||||||
if is_ours {
|
if is_ours {
|
||||||
@@ -33,7 +41,7 @@ struct DMView: View {
|
|||||||
|
|
||||||
let should_show_img = should_show_images(settings: damus_state.settings, contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey)
|
let should_show_img = should_show_images(settings: damus_state.settings, contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey)
|
||||||
|
|
||||||
NoteContentView(damus_state: damus_state, event: event, show_images: should_show_img, size: .normal, artifacts: .just_content(event.get_content(damus_state.keypair.privkey)), options: [])
|
NoteContentView(damus_state: damus_state, event: event, show_images: should_show_img, size: .normal, artifacts: .just_content(event.get_content(damus_state.keypair.privkey)), options: dm_options)
|
||||||
.padding([.top, .leading, .trailing], 10)
|
.padding([.top, .leading, .trailing], 10)
|
||||||
.padding([.bottom], 25)
|
.padding([.bottom], 25)
|
||||||
.background(VisualEffectView(effect: UIBlurEffect(style: .prominent))
|
.background(VisualEffectView(effect: UIBlurEffect(style: .prominent))
|
||||||
|
|||||||
@@ -51,10 +51,18 @@ struct DirectMessagesView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var options: EventViewOptions {
|
||||||
|
if self.damus_state.settings.translate_dms {
|
||||||
|
return [.truncate_content]
|
||||||
|
}
|
||||||
|
|
||||||
|
return [.truncate_content, .no_translate]
|
||||||
|
}
|
||||||
|
|
||||||
func MaybeEvent(_ tup: (String, DirectMessageModel)) -> some View {
|
func MaybeEvent(_ tup: (String, DirectMessageModel)) -> some View {
|
||||||
Group {
|
Group {
|
||||||
if let ev = tup.1.events.last {
|
if let ev = tup.1.events.last {
|
||||||
EventView(damus: damus_state, event: ev, pubkey: tup.0)
|
EventView(damus: damus_state, event: ev, pubkey: tup.0, options: options)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
pubkey = tup.0
|
pubkey = tup.0
|
||||||
active_model = tup.1
|
active_model = tup.1
|
||||||
|
|||||||
@@ -22,25 +22,11 @@ struct EventView: View {
|
|||||||
|
|
||||||
@EnvironmentObject var action_bar: ActionBarModel
|
@EnvironmentObject var action_bar: ActionBarModel
|
||||||
|
|
||||||
init(damus: DamusState, event: NostrEvent, options: EventViewOptions) {
|
init(damus: DamusState, event: NostrEvent, pubkey: String? = nil, options: EventViewOptions = []) {
|
||||||
self.event = event
|
self.event = event
|
||||||
self.options = options
|
self.options = options
|
||||||
self.damus = damus
|
self.damus = damus
|
||||||
self.pubkey = event.pubkey
|
self.pubkey = pubkey ?? event.pubkey
|
||||||
}
|
|
||||||
|
|
||||||
init(damus: DamusState, event: NostrEvent) {
|
|
||||||
self.event = event
|
|
||||||
self.options = []
|
|
||||||
self.damus = damus
|
|
||||||
self.pubkey = event.pubkey
|
|
||||||
}
|
|
||||||
|
|
||||||
init(damus: DamusState, event: NostrEvent, pubkey: String) {
|
|
||||||
self.event = event
|
|
||||||
self.options = [.no_action_bar]
|
|
||||||
self.damus = damus
|
|
||||||
self.pubkey = pubkey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ struct EventViewOptions: OptionSet {
|
|||||||
static let wide = EventViewOptions(rawValue: 1 << 3)
|
static let wide = EventViewOptions(rawValue: 1 << 3)
|
||||||
static let truncate_content = EventViewOptions(rawValue: 1 << 4)
|
static let truncate_content = EventViewOptions(rawValue: 1 << 4)
|
||||||
static let pad_content = EventViewOptions(rawValue: 1 << 5)
|
static let pad_content = EventViewOptions(rawValue: 1 << 5)
|
||||||
|
static let no_translate = EventViewOptions(rawValue: 1 << 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TextEvent: View {
|
struct TextEvent: View {
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ struct NoteContentView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if size == .selected || damus_state.settings.auto_translate {
|
if !options.contains(.no_translate) && (size == .selected || damus_state.settings.auto_translate) {
|
||||||
if with_padding {
|
if with_padding {
|
||||||
translateView
|
translateView
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
|||||||
@@ -69,6 +69,11 @@ struct TranslationSettingsView: View {
|
|||||||
Toggle(NSLocalizedString("Automatically translate notes", comment: "Toggle to automatically translate notes."), isOn: $settings.auto_translate)
|
Toggle(NSLocalizedString("Automatically translate notes", comment: "Toggle to automatically translate notes."), isOn: $settings.auto_translate)
|
||||||
.toggleStyle(.switch)
|
.toggleStyle(.switch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if settings.translation_service != .none {
|
||||||
|
Toggle(NSLocalizedString("Translate DMs", comment: "Toggle to translate direct messages."), isOn: $settings.translate_dms)
|
||||||
|
.toggleStyle(.switch)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle("Translation")
|
.navigationTitle("Translation")
|
||||||
|
|||||||
Reference in New Issue
Block a user