ndb: switch to nostrdb notes
This is a refactor of the codebase to use a more memory-efficient representation of notes. It should also be much faster at decoding since we're using a custom C json parser now. Changelog-Changed: Improved memory usage and performance when processing events
This commit is contained in:
@@ -10,17 +10,23 @@ import SwiftUI
|
||||
struct ReplyView: View {
|
||||
let replying_to: NostrEvent
|
||||
let damus: DamusState
|
||||
|
||||
@Binding var originalReferences: [ReferencedId]
|
||||
@Binding var references: [ReferencedId]
|
||||
|
||||
let original_pubkeys: [Pubkey]
|
||||
@Binding var filtered_pubkeys: Set<Pubkey>
|
||||
@State var participantsShown: Bool = false
|
||||
|
||||
|
||||
var references: [Pubkey] {
|
||||
original_pubkeys.filter { pk in
|
||||
!filtered_pubkeys.contains(pk)
|
||||
}
|
||||
}
|
||||
|
||||
var ReplyingToSection: some View {
|
||||
HStack {
|
||||
Group {
|
||||
let names = references.pRefs
|
||||
let names = references
|
||||
.map { pubkey in
|
||||
let pk = pubkey.ref_id
|
||||
let pk = pubkey
|
||||
let prof = damus.profiles.lookup(id: pk)
|
||||
return "@" + Profile.displayName(profile: prof, pubkey: pk).username.truncate(maxLength: 50)
|
||||
}
|
||||
@@ -40,11 +46,15 @@ struct ReplyView: View {
|
||||
}
|
||||
.sheet(isPresented: $participantsShown) {
|
||||
if #available(iOS 16.0, *) {
|
||||
ParticipantsView(damus_state: damus, references: $references, originalReferences: $originalReferences)
|
||||
ParticipantsView(damus_state: damus,
|
||||
original_pubkeys: self.original_pubkeys,
|
||||
filtered_pubkeys: $filtered_pubkeys)
|
||||
.presentationDetents([.medium, .large])
|
||||
.presentationDragIndicator(.visible)
|
||||
} else {
|
||||
ParticipantsView(damus_state: damus, references: $references, originalReferences: $originalReferences)
|
||||
ParticipantsView(damus_state: damus,
|
||||
original_pubkeys: self.original_pubkeys,
|
||||
filtered_pubkeys: $filtered_pubkeys)
|
||||
}
|
||||
}
|
||||
.padding(.leading, 75)
|
||||
@@ -81,10 +91,16 @@ struct ReplyView: View {
|
||||
struct ReplyView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack {
|
||||
ReplyView(replying_to: test_note, damus: test_damus_state(), originalReferences: .constant([]), references: .constant([]))
|
||||
ReplyView(replying_to: test_note,
|
||||
damus: test_damus_state(),
|
||||
original_pubkeys: [],
|
||||
filtered_pubkeys: .constant([]))
|
||||
.frame(height: 300)
|
||||
|
||||
ReplyView(replying_to: test_longform_event.event, damus: test_damus_state(), originalReferences: .constant([]), references: .constant([]))
|
||||
ReplyView(replying_to: test_longform_event.event,
|
||||
damus: test_damus_state(),
|
||||
original_pubkeys: [],
|
||||
filtered_pubkeys: .constant([]))
|
||||
.frame(height: 300)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user