Rewrite settings to result

This commit is contained in:
micialware committed 2026-08-24 18:23:29 +03:00
1 parent 8841a51897
commit 6f8adde06b
2 files changed
+48 -30

No files matched your search

+22 -18
View File
@@ -1,20 +1,20 @@
use crate::app::{AppState, fill_state};
use crate::data_provider::settings::{delete_settings, set_setting};
use crate::data_provider::web_api::*;
use crate::navigation::Page::PreviousPage;
use crate::navigation::{NavigatedPage, Page, RootMessage};
use crate::styling::*;
use crate::notification::{NotificationData, NotificationRequest};
use crate::pages::sync::SyncMessage::*;
use crate::styling::*;
use crate::{push_error, push_error_task};
use iced::widget::button::danger;
use iced::widget::container::rounded_box;
use iced::widget::{button, column, container, progress_bar, row, space, text, toggler};
use iced::{Center, Element, Fill, Font, Length, Task};
use log::error;
use parking_lot::Mutex;
use std::sync::Arc;
use std::time::Duration;
use log::error;
use crate::app::{fill_state, AppState};
use crate::notification::{NotificationRequest, NotificationData};
use crate::push_error;
#[derive(Clone)]
pub enum SyncMessage {
@@ -62,11 +62,9 @@ impl NavigatedPage<SyncMessage> for SyncState {
.map(|_val: String| RootMessage::Sync(KeyCopied));
}
InitSync => {
return Task::perform(first_sync(), |id| {
match id {
Ok(id) => RootMessage::Sync(IdReceived(id)),
Err(err) => push_error!(err)
}
return Task::perform(first_sync(), |id| match id {
Ok(id) => RootMessage::Sync(IdReceived(id)),
Err(err) => push_error!(err),
});
}
GetKey => {
@@ -80,7 +78,9 @@ impl NavigatedPage<SyncMessage> for SyncState {
}
let mut state = self.state.lock();
state.sync_data.key = Some(new_id.clone());
set_setting("SYNC_KEY".to_string(), new_id, &state.connection);
if let Err(err) = set_setting("SYNC_KEY".to_string(), new_id, &state.connection) {
return push_error_task!(err);
}
}
Send => {
self.prepare_to_db_interaction();
@@ -131,7 +131,9 @@ impl NavigatedPage<SyncMessage> for SyncState {
state.decks = updated_state.decks;
state.dictionary = updated_state.dictionary;
state.word_groups = updated_state.word_groups;
return Task::done(RootMessage::PushNotification(NotificationRequest::Info(NotificationData::DataLoaded)))
return Task::done(RootMessage::PushNotification(NotificationRequest::Info(
NotificationData::DataLoaded,
)));
}
Disable => {}
DisableSync => {
@@ -144,11 +146,13 @@ impl NavigatedPage<SyncMessage> for SyncState {
self.auto_fetch = !self.auto_fetch;
let mut state = self.state.lock();
state.sync_data.auto_web_fetch = self.auto_fetch;
set_setting(
if let Err(err) = set_setting(
"AUTO_WEB_FETCH".to_string(),
self.auto_fetch.to_string(),
&state.connection,
);
) {
return push_error_task!(err);
}
}
}
Task::none()
@@ -227,10 +231,10 @@ impl SyncState {
]
}
}
.spacing(DEFAULT_SPACING)
.align_x(Center)
.width(Length::Shrink)
.into()
.spacing(DEFAULT_SPACING)
.align_x(Center)
.width(Length::Shrink)
.into()
}
/* fn app_updater(&self) -> Element<'_, SyncMessage> {