damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 4996272942cc1da178364a20abbdc8d4cd21eef2
parent 094f63bcff341c41049e7808fca1e5a6f1d882d0
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  3 Apr 2023 11:30:05 -0700

Only truncate timeline text if enabled in settings

Changelog-Changed: Only truncate timeline text if enabled in settings

Diffstat:
Mdamus/Models/UserSettingsStore.swift | 7+++++++
Mdamus/Views/ConfigView.swift | 2++
Mdamus/Views/Events/TextEvent.swift | 4++--
Mdamus/Views/Timeline/InnerTimelineView.swift | 10+++++++++-
4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/damus/Models/UserSettingsStore.swift b/damus/Models/UserSettingsStore.swift @@ -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 diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift @@ -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.")) { diff --git a/damus/Views/Events/TextEvent.swift b/damus/Views/Events/TextEvent.swift @@ -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) diff --git a/damus/Views/Timeline/InnerTimelineView.swift b/damus/Views/Timeline/InnerTimelineView.swift @@ -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