idk bro, viewing works
This commit is contained in:
@@ -154,3 +154,13 @@ pub fn get_apps_by_ids(conn: &mut SqliteConnection, ids: &[String]) -> Vec<model
|
||||
.load::<models::App>(conn)
|
||||
.expect("Error loading apps by ids")
|
||||
}
|
||||
|
||||
pub fn get_blog_by_id(conn: &mut SqliteConnection, blog_id: &str) -> Option<models::Blog> {
|
||||
use crate::db::schema::blog;
|
||||
|
||||
blog::table
|
||||
.filter(blog::id.eq(blog_id))
|
||||
.first::<models::Blog>(conn)
|
||||
.optional()
|
||||
.expect("Error loading blog by id")
|
||||
}
|
||||
|
||||
+21
-1
@@ -121,6 +121,25 @@ fn get_apps_by_id(ids: Vec<String>) -> Vec<App> {
|
||||
db::get_apps_by_ids(&mut conn, &ids)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn get_blog(id: &str) -> Option<TempBlog> {
|
||||
let mut conn = establish_connection();
|
||||
let blog = db::get_blog_by_id(&mut conn, id);
|
||||
|
||||
blog.map(|b| {
|
||||
let linked_app_ids: Option<Vec<String>> = match &b.reference {
|
||||
Some(ids) => serde_json::from_str(ids).ok(),
|
||||
None => None,
|
||||
};
|
||||
TempBlog {
|
||||
id: b.id.clone(),
|
||||
title: b.title.clone(),
|
||||
content: b.content.clone(),
|
||||
linked_app_ids,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
@@ -132,7 +151,8 @@ pub fn run() {
|
||||
ping,
|
||||
get_blogs,
|
||||
save_blog,
|
||||
get_apps_by_id
|
||||
get_apps_by_id,
|
||||
get_blog
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
Reference in New Issue
Block a user