fix ordering on search, copy note

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-05-09 12:09:51 -07:00
parent cac139fff1
commit bd49c8a9d1
5 changed files with 22 additions and 5 deletions

View File

@@ -8,7 +8,7 @@
import Foundation
func insert_uniq_sorted_event(events: inout [NostrEvent], new_ev: NostrEvent) -> Bool {
func insert_uniq_sorted_event(events: inout [NostrEvent], new_ev: NostrEvent, cmp: (NostrEvent, NostrEvent) -> Bool) -> Bool {
var i: Int = 0
for event in events {
@@ -17,7 +17,7 @@ func insert_uniq_sorted_event(events: inout [NostrEvent], new_ev: NostrEvent) ->
return false
}
if new_ev.created_at < event.created_at {
if cmp(new_ev, event) {
events.insert(new_ev, at: i)
return true
}