mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 23:36:20 +00:00
feat(app): quick switcher also finds pages by block content
BlockHit carries the page id so a hit opens its page (journals included). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a6d566ff6f
commit
b44cbee038
9 files changed
+204
-30
No files matched your search
@@ -187,11 +187,12 @@ pub struct TitleHit {
|
||||
pub is_alias: bool,
|
||||
}
|
||||
|
||||
/// `((` autocomplete hit.
|
||||
/// A block matching a search (`((` autocomplete, quick switcher content results).
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct BlockHit {
|
||||
pub id: String,
|
||||
pub content: String,
|
||||
pub page_id: String,
|
||||
pub page_title: String,
|
||||
}
|
||||
|
||||
|
||||
@@ -79,14 +79,15 @@ impl SynapseGraph {
|
||||
let g = self.lock();
|
||||
// Read-only stopgap over the core tables until synapse-search lands.
|
||||
let mut st = g.conn().prepare_cached(
|
||||
"SELECT b.id, b.content, p.title FROM blocks b JOIN pages p ON p.id = b.page_id
|
||||
"SELECT b.id, b.content, p.id, p.title FROM blocks b JOIN pages p ON p.id = b.page_id
|
||||
WHERE b.content LIKE ?1 ESCAPE '\\' ORDER BY b.updated_at DESC LIMIT ?2",
|
||||
)?;
|
||||
let rows = st.query_map((pattern, limit), |r| {
|
||||
Ok(BlockHit {
|
||||
id: r.get(0)?,
|
||||
content: r.get(1)?,
|
||||
page_title: r.get(2)?,
|
||||
page_id: r.get(2)?,
|
||||
page_title: r.get(3)?,
|
||||
})
|
||||
})?;
|
||||
Ok(rows.collect::<std::result::Result<_, _>>()?)
|
||||
|
||||
@@ -3568,10 +3568,12 @@ impl SseDecode for crate::api::dto::BlockHit {
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
let mut var_id = <String>::sse_decode(deserializer);
|
||||
let mut var_content = <String>::sse_decode(deserializer);
|
||||
let mut var_pageId = <String>::sse_decode(deserializer);
|
||||
let mut var_pageTitle = <String>::sse_decode(deserializer);
|
||||
return crate::api::dto::BlockHit {
|
||||
id: var_id,
|
||||
content: var_content,
|
||||
page_id: var_pageId,
|
||||
page_title: var_pageTitle,
|
||||
};
|
||||
}
|
||||
@@ -4664,6 +4666,7 @@ impl flutter_rust_bridge::IntoDart for crate::api::dto::BlockHit {
|
||||
[
|
||||
self.id.into_into_dart().into_dart(),
|
||||
self.content.into_into_dart().into_dart(),
|
||||
self.page_id.into_into_dart().into_dart(),
|
||||
self.page_title.into_into_dart().into_dart(),
|
||||
]
|
||||
.into_dart()
|
||||
@@ -5183,6 +5186,7 @@ impl SseEncode for crate::api::dto::BlockHit {
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
<String>::sse_encode(self.id, serializer);
|
||||
<String>::sse_encode(self.content, serializer);
|
||||
<String>::sse_encode(self.page_id, serializer);
|
||||
<String>::sse_encode(self.page_title, serializer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user