txn: fix subtle transaction inheritence bugs

This fixes subtle bugs with transaction inheritence. Since we were not
passing the inherited state to moved value, we were sometimes committing
transactions more than once.

Changelog-Fixed: Fix many nostrdb transaction related crashes
This commit is contained in:
William Casarin
2024-01-26 14:03:49 -08:00
parent f190b6414c
commit e3642b92d1
8 changed files with 53 additions and 42 deletions

View File

@@ -118,10 +118,11 @@ struct QRCodeView: View {
var QRView: some View {
VStack(alignment: .center) {
let profile_txn = damus_state.profiles.lookup(id: pubkey)
let profile_txn = damus_state.profiles.lookup(id: pubkey, txn_name: "qrview-profile")
let profile = profile_txn?.unsafeUnownedValue
let our_profile_txn = damus_state.profiles.lookup(id: damus_state.pubkey)
let our_profile = our_profile_txn?.unsafeUnownedValue
let our_profile = profile_txn.flatMap({ ptxn in
damus_state.ndb.lookup_profile_with_txn(damus_state.pubkey, txn: ptxn)?.profile
})
if our_profile?.picture != nil {
ProfilePicView(pubkey: pubkey, size: 90.0, highlight: .custom(DamusColors.white, 3.0), profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)