commit c6f7eecb6e6083751151ab1a5681e8e68dfefc77
parent dc96799a585f06207e3bbccc5bce1de7aa473893
Author: William Casarin <jb55@jb55.com>
Date: Tue, 31 Dec 2024 09:59:19 -0800
don't create transaction if we don't need to
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/html.rs b/src/html.rs
@@ -84,7 +84,6 @@ pub fn serve_note_html(
// 5: formatted date
// 6: pfp url
- let txn = Transaction::new(&app.ndb)?;
let note_key = match note_rd.note_rd {
NoteRenderData::Note(note_key) => note_key,
NoteRenderData::Missing(note_id) => {
@@ -93,6 +92,8 @@ pub fn serve_note_html(
}
};
+ let txn = Transaction::new(&app.ndb)?;
+
let note = if let Ok(note) = app.ndb.get_note_by_key(&txn, note_key) {
note
} else {