ndb/txn: make transactions failable
Since there may be situations where we close and re-open the database,
we need to make sure transactions fail when the database is not open.
Make NdbTxn an init?() constructor and check for ndb.closed. If it's
closed, then fail transaction construction.
This fixes crashes during high database activity when switching from
background to foreground and vice-versa.
Fixes: da2bdad18d ("nostrdb: close database when backgrounded")
This commit is contained in:
@@ -24,11 +24,10 @@ struct ReplyView: View {
|
||||
var ReplyingToSection: some View {
|
||||
HStack {
|
||||
Group {
|
||||
let txn = NdbTxn(ndb: damus.ndb)
|
||||
let names = references
|
||||
.map { pubkey in
|
||||
let pk = pubkey
|
||||
let prof = damus.ndb.lookup_profile_with_txn(pk, txn: txn)?.profile
|
||||
let prof = damus.ndb.lookup_profile(pk)?.unsafeUnownedValue?.profile
|
||||
return "@" + Profile.displayName(profile: prof, pubkey: pk).username.truncate(maxLength: 50)
|
||||
}
|
||||
.joined(separator: " ")
|
||||
|
||||
Reference in New Issue
Block a user