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,
selected_note_id: &'a [u8; 32],
) -> &'a [u8; 32] {
let selected_note_key = if let Ok(key) = ndb
.get_notekey_by_id(txn, selected_note_id)
.map(NoteKey::new)
{
let selected_note_key = if let Ok(key) = ndb.get_notekey_by_id(txn, selected_note_id) {
key
} else {
return selected_note_id;

View File

@@ -5,7 +5,7 @@ use crate::{
ui::note::NoteOptions,
};
use nostrdb::{Ndb, NoteKey, Transaction};
use nostrdb::{Ndb, Transaction};
use notedeck::{ImageCache, MuteFun, NoteCache, UnknownIds};
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> {
let txn = Transaction::new(self.ndb).expect("txn");
let selected_note_key = if let Ok(key) = self
.ndb
.get_notekey_by_id(&txn, self.selected_note_id)
.map(NoteKey::new)
{
key
} else {
// TODO: render 404 ?
return None;
};
let selected_note_key =
if let Ok(key) = self.ndb.get_notekey_by_id(&txn, self.selected_note_id) {
key
} else {
// TODO: render 404 ?
return None;
};
ui.label(
egui::RichText::new("Threads ALPHA! It's not done. Things will be broken.")