Skip to content

Commit

Permalink
ndb.get_notekey_by_id now returns NoteKey
Browse files Browse the repository at this point in the history
Closes: #584
  • Loading branch information
ksedgwic authored and jb55 committed Dec 17, 2024
1 parent e1a55c6 commit 926a3f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
5 changes: 1 addition & 4 deletions crates/notedeck/src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 8 additions & 11 deletions crates/notedeck_columns/src/ui/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.")
Expand Down

0 comments on commit 926a3f8

Please sign in to comment.