Browse Source

clicking chat quotes now just expands thems

jumping to them is kind of annoying

Changelog-Changed: Clicking a chatroom quote reply will now expand it instead of jumping to it
Signed-off-by: William Casarin <jb55@jb55.com>
profile-edit
William Casarin 2 years ago
parent
commit
65710eeb5e
  1. 6
      damus/Views/ChatView.swift
  2. 12
      damus/Views/EventDetailView.swift
  3. 3
      damus/Views/ReplyQuoteView.swift

6
damus/Views/ChatView.swift

@ -14,6 +14,7 @@ struct ChatView: View {
let damus_state: DamusState
@State var expand_reply: Bool = false
@EnvironmentObject var thread: ThreadModel
var just_started: Bool {
@ -96,8 +97,11 @@ struct ChatView: View {
if let ref_id = thread.replies.lookup(event.id) {
if !is_reply_to_prev() {
ReplyQuoteView(privkey: damus_state.keypair.privkey, quoter: event, event_id: ref_id, image_cache: damus_state.image_cache, profiles: damus_state.profiles)
.frame(maxHeight: 100)
.frame(maxHeight: expand_reply ? nil : 100)
.environmentObject(thread)
.onTapGesture {
expand_reply = !expand_reply
}
ReplyDescription
}
}

12
damus/Views/EventDetailView.swift

@ -66,8 +66,9 @@ struct EventDetailView: View {
.onTapGesture {
//self.uncollapse_section(scroller: proxy, c: c)
//self.toggle_collapse_thread(scroller: proxy, id: nil)
let ev = thread.events[c.start]
if let ev = thread.events[safe: c.start] {
thread.set_active_event(ev, privkey: damus.keypair.privkey)
}
toggle_thread_view()
}
case .event(let ev, let highlight):
@ -333,3 +334,12 @@ func scroll_to_event(scroller: ScrollViewProxy, id: String, delay: Double, anima
}
}
*/
extension Collection {
/// Returns the element at the specified index if it is within bounds, otherwise nil.
subscript (safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}

3
damus/Views/ReplyQuoteView.swift

@ -50,9 +50,6 @@ struct ReplyQuoteView: View {
.padding(4)
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
.onTapGesture {
NotificationCenter.default.post(name: .select_quote, object: event)
}
} else {
ProgressView()
.progressViewStyle(.circular)

Loading…
Cancel
Save