Finishing deunprap
This commit is contained in:
1 parent
a60ed37cd4
commit
1d24fe2631
5 files changed
+15
-9
No files matched your search
@@ -15,7 +15,7 @@ pub fn get_history_of_set(id: Id) -> Result<Vec<HistoryItem>, NotificationData>
|
|||||||
let head = app_dir.clone().join(format!("set_{}_history.csv", id));
|
let head = app_dir.clone().join(format!("set_{}_history.csv", id));
|
||||||
let mut lines = Vec::new();
|
let mut lines = Vec::new();
|
||||||
|
|
||||||
append_lines_if_exists(head, &mut lines);
|
append_lines_if_exists(head, &mut lines)?;
|
||||||
lines.reverse();
|
lines.reverse();
|
||||||
Ok(parse_history_items(lines))
|
Ok(parse_history_items(lines))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use crate::notification::{MaybeError, NotificationData};
|
|
||||||
use crate::notification::NotificationData::{DbLoadError, DbSaveError};
|
use crate::notification::NotificationData::{DbLoadError, DbSaveError};
|
||||||
use iced::futures::StreamExt;
|
use crate::notification::{MaybeError, NotificationData};
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
|
|
||||||
pub fn get_setting(key: String, connection: &Connection) -> Option<String> {
|
pub fn get_setting(key: String, connection: &Connection) -> Option<String> {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ pub async fn send_data(id: String) -> MaybeError {
|
|||||||
.text()
|
.text()
|
||||||
.await
|
.await
|
||||||
.map_err(|_| WebApiUnavailable)?;
|
.map_err(|_| WebApiUnavailable)?;
|
||||||
set_local_version(new_version.parse::<u32>().unwrap_or_default()).await;
|
set_local_version(new_version.parse::<u32>().unwrap_or_default()).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ pub async fn load_data(id: String, temp: bool) -> MaybeError {
|
|||||||
.text()
|
.text()
|
||||||
.await
|
.await
|
||||||
.map_err(|_| WebApiUnavailable)?;
|
.map_err(|_| WebApiUnavailable)?;
|
||||||
set_local_version(version.parse::<u32>().unwrap_or_default()).await;
|
set_local_version(version.parse::<u32>().unwrap_or_default()).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -178,7 +178,7 @@ impl ScreenState {
|
|||||||
if web > local {
|
if web > local {
|
||||||
info!("Web version is newer than local version");
|
info!("Web version is newer than local version");
|
||||||
load_data(string, true).await?;
|
load_data(string, true).await?;
|
||||||
set_local_version(web).await;
|
set_local_version(web).await?;
|
||||||
} else {
|
} else {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,7 @@ impl ScreenState {
|
|||||||
return match page {
|
return match page {
|
||||||
Repetition(page) => page.press(&message),
|
Repetition(page) => page.press(&message),
|
||||||
_ => Task::none(),
|
_ => Task::none(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -139,8 +139,15 @@ impl NavigatedPage<SyncMessage> for SyncState {
|
|||||||
DisableSync => {
|
DisableSync => {
|
||||||
let mut state = self.state.lock();
|
let mut state = self.state.lock();
|
||||||
state.sync_data.key = None;
|
state.sync_data.key = None;
|
||||||
delete_settings("SYNC_KEY".to_string(), &state.connection);
|
let save_result = || {
|
||||||
delete_settings("AUTO_WEB_FETCH".to_string(), &state.connection);
|
delete_settings("SYNC_KEY".to_string(), &state.connection)?;
|
||||||
|
delete_settings("AUTO_WEB_FETCH".to_string(), &state.connection)?;
|
||||||
|
Ok::<(), NotificationData>(())
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(error) = save_result() {
|
||||||
|
return push_error_task!(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SwitchAutoSync => {
|
SwitchAutoSync => {
|
||||||
self.auto_fetch = !self.auto_fetch;
|
self.auto_fetch = !self.auto_fetch;
|
||||||
|
|||||||
Reference in new issue
Block a user