Bump app version to 0.5.0 and implement offline mode support across components
- Added offline detection logic with `OfflineContext` to improve app functionality in offline scenarios. - Integrated Tauri IPC functions to handle local tool settings and character attributes when offline. - Refined indentation logic in `TextEditor` for better compatibility with WebKit engines. - Removed unused `indent` property and related settings in editor components to simplify configuration. - Updated locale files with improved translation consistency and parameterized placeholders.
This commit is contained in:
@@ -288,7 +288,7 @@ pub fn fetch_whole_chapter(conn: &Connection, user_id: &str, chapter_id: &str, v
|
||||
.query_row(params![version, chapter_id, user_id], |query_row| {
|
||||
Ok(ChapterContentQueryResult {
|
||||
chapter_id: query_row.get(0)?, title: query_row.get(1)?,
|
||||
chapter_order: query_row.get(2)?, words_count: query_row.get(3)?,
|
||||
chapter_order: query_row.get(2)?, words_count: query_row.get::<_, Option<i64>>(3)?.unwrap_or(0),
|
||||
content: query_row.get::<_, Option<String>>(4)?.unwrap_or_default(),
|
||||
version: query_row.get::<_, Option<i64>>(5)?.unwrap_or(2),
|
||||
})
|
||||
|
||||
@@ -82,11 +82,13 @@ pub fn get_all_locations(conn: &Connection, user_id: &str, book_id: &str, lang:
|
||||
let element_idx: usize = match element_index {
|
||||
Some(idx) => idx,
|
||||
None => {
|
||||
let decrypted_name: String = decrypt_data_with_user_key(record.element_name.as_deref().unwrap_or(""), &user_key)?;
|
||||
let decrypted_description: String = if let Some(ref element_description) = record.element_description {
|
||||
decrypt_data_with_user_key(element_description, &user_key)?
|
||||
} else {
|
||||
String::new()
|
||||
let decrypted_name: String = match record.element_name.as_deref() {
|
||||
Some(name) if !name.is_empty() => decrypt_data_with_user_key(name, &user_key)?,
|
||||
_ => String::new(),
|
||||
};
|
||||
let decrypted_description: String = match record.element_description.as_deref() {
|
||||
Some(description) if !description.is_empty() => decrypt_data_with_user_key(description, &user_key)?,
|
||||
_ => String::new(),
|
||||
};
|
||||
location_array[location_idx].elements.push(Element {
|
||||
id: element_id.clone(),
|
||||
@@ -105,11 +107,13 @@ pub fn get_all_locations(conn: &Connection, user_id: &str, book_id: &str, lang:
|
||||
.any(|sub| sub.id == *sub_element_id);
|
||||
|
||||
if !sub_element_exists {
|
||||
let decrypted_name: String = decrypt_data_with_user_key(record.sub_elem_name.as_deref().unwrap_or(""), &user_key)?;
|
||||
let decrypted_description: String = if let Some(ref sub_elem_description) = record.sub_elem_description {
|
||||
decrypt_data_with_user_key(sub_elem_description, &user_key)?
|
||||
} else {
|
||||
String::new()
|
||||
let decrypted_name: String = match record.sub_elem_name.as_deref() {
|
||||
Some(name) if !name.is_empty() => decrypt_data_with_user_key(name, &user_key)?,
|
||||
_ => String::new(),
|
||||
};
|
||||
let decrypted_description: String = match record.sub_elem_description.as_deref() {
|
||||
Some(description) if !description.is_empty() => decrypt_data_with_user_key(description, &user_key)?,
|
||||
_ => String::new(),
|
||||
};
|
||||
location_array[location_idx].elements[element_idx].sub_elements.push(SubElement {
|
||||
id: sub_element_id.clone(),
|
||||
@@ -325,11 +329,13 @@ pub fn get_location_tags(conn: &Connection, user_id: &str, book_id: &str, lang:
|
||||
if processed_ids.contains(sub_element_id) {
|
||||
continue;
|
||||
}
|
||||
let decrypted_name: String = decrypt_data_with_user_key(record.sub_elem_name.as_deref().unwrap_or(""), &user_key)?;
|
||||
let decrypted_description: String = if let Some(ref sub_elem_description) = record.sub_elem_description {
|
||||
decrypt_data_with_user_key(sub_elem_description, &user_key)?
|
||||
} else {
|
||||
String::new()
|
||||
let decrypted_name: String = match record.sub_elem_name.as_deref() {
|
||||
Some(name) if !name.is_empty() => decrypt_data_with_user_key(name, &user_key)?,
|
||||
_ => String::new(),
|
||||
};
|
||||
let decrypted_description: String = match record.sub_elem_description.as_deref() {
|
||||
Some(description) if !description.is_empty() => decrypt_data_with_user_key(description, &user_key)?,
|
||||
_ => String::new(),
|
||||
};
|
||||
sub_elements.push(SubElement {
|
||||
id: sub_element_id.clone(),
|
||||
@@ -343,10 +349,9 @@ pub fn get_location_tags(conn: &Connection, user_id: &str, book_id: &str, lang:
|
||||
continue;
|
||||
}
|
||||
let decrypted_name: String = decrypt_data_with_user_key(&record.element_name, &user_key)?;
|
||||
let decrypted_description: String = if let Some(ref element_description) = record.element_description {
|
||||
decrypt_data_with_user_key(element_description, &user_key)?
|
||||
} else {
|
||||
String::new()
|
||||
let decrypted_description: String = match record.element_description.as_deref() {
|
||||
Some(description) if !description.is_empty() => decrypt_data_with_user_key(description, &user_key)?,
|
||||
_ => String::new(),
|
||||
};
|
||||
sub_elements.push(SubElement {
|
||||
id: record.element_id.clone(),
|
||||
|
||||
Reference in New Issue
Block a user