Only truncate timeline text if enabled in settings

Changelog-Changed: Only truncate timeline text if enabled in settings
This commit is contained in:
William Casarin
2023-04-03 11:30:05 -07:00
parent 094f63bcff
commit 4996272942
4 changed files with 20 additions and 3 deletions

View File

@@ -128,6 +128,12 @@ class UserSettingsStore: ObservableObject {
}
}
@Published var truncate_timeline_text: Bool {
didSet {
UserDefaults.standard.set(truncate_timeline_text, forKey: "truncate_timeline_text")
}
}
@Published var auto_translate: Bool {
didSet {
UserDefaults.standard.set(auto_translate, forKey: "auto_translate")
@@ -221,6 +227,7 @@ class UserSettingsStore: ObservableObject {
left_handed = UserDefaults.standard.object(forKey: "left_handed") as? Bool ?? false
zap_vibration = UserDefaults.standard.object(forKey: "zap_vibration") as? Bool ?? false
truncate_timeline_text = UserDefaults.standard.object(forKey: "truncate_timeline_text") as? Bool ?? false
disable_animation = should_disable_image_animation()
auto_translate = UserDefaults.standard.object(forKey: "auto_translate") as? Bool ?? true
show_only_preferred_languages = UserDefaults.standard.object(forKey: "show_only_preferred_languages") as? Bool ?? false

View File

@@ -214,6 +214,8 @@ struct ConfigView: View {
.toggleStyle(.switch)
Toggle(NSLocalizedString("Zap Vibration", comment: "Setting to enable vibration on zap"), isOn: $settings.zap_vibration)
.toggleStyle(.switch)
Toggle(NSLocalizedString("Truncate text in timeline", comment: "Truncate text in timeline"), isOn: $settings.truncate_timeline_text)
.toggleStyle(.switch)
}
Section(NSLocalizedString("Images", comment: "Section title for images configuration.")) {

View File

@@ -80,7 +80,7 @@ struct TextEvent: View {
}
.padding(.horizontal)
EvBody(options: [.truncate_content, .pad_content])
EvBody(options: self.options.union(.pad_content))
if let mention = first_eref_mention(ev: event, privkey: damus.keypair.privkey) {
Mention(mention)
@@ -149,7 +149,7 @@ struct TextEvent: View {
TopPart(is_anon: is_anon)
ReplyPart
EvBody(options: [])
EvBody(options: self.options)
if let mention = first_eref_mention(ev: event, privkey: damus.keypair.privkey) {
Mention(mention)

View File

@@ -25,6 +25,14 @@ struct InnerTimelineView: View {
self._nav_target = State(initialValue: test_event)
}
var event_options: EventViewOptions {
if self.damus.settings.truncate_timeline_text {
return [.wide, .truncate_content]
}
return [.wide]
}
var body: some View {
let thread = ThreadModel(event: nav_target, damus_state: damus)
let dest = ThreadView(state: damus, thread: thread)
@@ -37,7 +45,7 @@ struct InnerTimelineView: View {
EmptyTimelineView()
} else {
ForEach(events.filter(filter), id: \.id) { (ev: NostrEvent) in
EventView(damus: damus, event: ev, options: [.wide])
EventView(damus: damus, event: ev, options: event_options)
.onTapGesture {
nav_target = ev.inner_event ?? ev
navigating = true