ndb.get_notekey_by_id now returns NoteKey

Closes: https://github.com/damus-io/notedeck/pull/584
This commit is contained in:
Ken Sedgwick
2024-12-16 16:20:47 -08:00
committed by William Casarin
parent e1a55c6532
commit 926a3f80f4
2 changed files with 9 additions and 15 deletions

View File

@@ -49,10 +49,7 @@ pub fn root_note_id_from_selected_id<'a>(
txn: &'a Transaction, txn: &'a Transaction,
selected_note_id: &'a [u8; 32], selected_note_id: &'a [u8; 32],
) -> &'a [u8; 32] { ) -> &'a [u8; 32] {
let selected_note_key = if let Ok(key) = ndb let selected_note_key = if let Ok(key) = ndb.get_notekey_by_id(txn, selected_note_id) {
.get_notekey_by_id(txn, selected_note_id)
.map(NoteKey::new)
{
key key
} else { } else {
return selected_note_id; return selected_note_id;

View File

@@ -5,7 +5,7 @@ use crate::{
ui::note::NoteOptions, ui::note::NoteOptions,
}; };
use nostrdb::{Ndb, NoteKey, Transaction}; use nostrdb::{Ndb, Transaction};
use notedeck::{ImageCache, MuteFun, NoteCache, UnknownIds}; use notedeck::{ImageCache, MuteFun, NoteCache, UnknownIds};
use tracing::error; use tracing::error;
@@ -54,16 +54,13 @@ impl<'a> ThreadView<'a> {
pub fn ui(&mut self, ui: &mut egui::Ui, is_muted: &MuteFun) -> Option<NoteAction> { pub fn ui(&mut self, ui: &mut egui::Ui, is_muted: &MuteFun) -> Option<NoteAction> {
let txn = Transaction::new(self.ndb).expect("txn"); let txn = Transaction::new(self.ndb).expect("txn");
let selected_note_key = if let Ok(key) = self let selected_note_key =
.ndb if let Ok(key) = self.ndb.get_notekey_by_id(&txn, self.selected_note_id) {
.get_notekey_by_id(&txn, self.selected_note_id) key
.map(NoteKey::new) } else {
{ // TODO: render 404 ?
key return None;
} else { };
// TODO: render 404 ?
return None;
};
ui.label( ui.label(
egui::RichText::new("Threads ALPHA! It's not done. Things will be broken.") egui::RichText::new("Threads ALPHA! It's not done. Things will be broken.")