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:
@@ -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 {
|
||||
HStack {
|
||||
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)
|
||||
|
||||
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([.bottom], 25)
|
||||
.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 {
|
||||
Group {
|
||||
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 {
|
||||
pubkey = tup.0
|
||||
active_model = tup.1
|
||||
|
||||
@@ -22,25 +22,11 @@ struct EventView: View {
|
||||
|
||||
@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.options = options
|
||||
self.damus = damus
|
||||
self.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
|
||||
self.pubkey = pubkey ?? event.pubkey
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
|
||||
@@ -15,6 +15,7 @@ struct EventViewOptions: OptionSet {
|
||||
static let wide = EventViewOptions(rawValue: 1 << 3)
|
||||
static let truncate_content = EventViewOptions(rawValue: 1 << 4)
|
||||
static let pad_content = EventViewOptions(rawValue: 1 << 5)
|
||||
static let no_translate = EventViewOptions(rawValue: 1 << 6)
|
||||
}
|
||||
|
||||
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 {
|
||||
translateView
|
||||
.padding(.horizontal)
|
||||
|
||||
@@ -69,6 +69,11 @@ struct TranslationSettingsView: View {
|
||||
Toggle(NSLocalizedString("Automatically translate notes", comment: "Toggle to automatically translate notes."), isOn: $settings.auto_translate)
|
||||
.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")
|
||||
|
||||
Reference in New Issue
Block a user