More notifications
This commit is contained in:
1 parent
f113d2b3d7
commit
3fcfe95720
4 files changed
+43
-32
No files matched your search
+20
-15
@@ -1,3 +1,4 @@
|
||||
use crate::app::{fill_state, AppState};
|
||||
use crate::data_provider::history::{get_history_of_set, history_dir};
|
||||
use crate::data_provider::sqlite::{create_db, default_connection};
|
||||
use crate::data_provider::web_api::{get_local_version, get_web_version, load_data, set_local_version};
|
||||
@@ -8,8 +9,8 @@ use crate::import::{ImportMessage, ImportState};
|
||||
use crate::lang::Id;
|
||||
use crate::message_navigation;
|
||||
use crate::navigation::Page::*;
|
||||
use crate::navigation::RootMessage::{DataLoaded, Keyboard, PushNotification, UpdateData, Notification};
|
||||
use crate::notification::{NotificationRequest, NotificationManager, NotificationMessage};
|
||||
use crate::navigation::RootMessage::{DataLoaded, Keyboard, Notification, PushNotification, UpdateData};
|
||||
use crate::notification::{NotificationData, NotificationManager, NotificationMessage, NotificationRequest};
|
||||
use crate::quiz::{QuizMessage, QuizState};
|
||||
use crate::randomizer::{RandomizerMessage, RandomizerState};
|
||||
use crate::repetition::{RepetitionMessage, RepetitionState};
|
||||
@@ -22,18 +23,16 @@ use crate::sync::{SyncMessage, SyncState};
|
||||
use crate::view_navigation;
|
||||
use crate::word::{WordMessage, WordState};
|
||||
use crate::writing::{WritingMessage, WritingState};
|
||||
use crate::app::{fill_state, AppState};
|
||||
use chrono::NaiveDate;
|
||||
use hashbrown::HashMap;
|
||||
use iced::keyboard::Event;
|
||||
use iced::widget::stack;
|
||||
use iced::{Element, Task};
|
||||
use iced_core::Length::Fill;
|
||||
use parking_lot::Mutex;
|
||||
use reqwest::Error;
|
||||
use rusqlite::Connection;
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
use iced_core::Length::Fill;
|
||||
|
||||
impl Default for ScreenState {
|
||||
fn default() -> Self {
|
||||
@@ -108,15 +107,21 @@ impl ScreenState {
|
||||
let key = state_guard.sync_data.key.clone().unwrap();
|
||||
final_task = Task::batch([
|
||||
reading_additional_task,
|
||||
Task::perform(Self::load_web_backup(key), |result| {
|
||||
if let Ok(update) = result
|
||||
&& update
|
||||
{
|
||||
UpdateData
|
||||
} else {
|
||||
RootMessage::None
|
||||
Task::perform(
|
||||
Self::load_web_backup(key),
|
||||
|result| {
|
||||
match result {
|
||||
Ok(update) => {
|
||||
if update {
|
||||
UpdateData
|
||||
}else {
|
||||
RootMessage::None
|
||||
}
|
||||
}
|
||||
Err(err) => PushNotification(NotificationRequest::Warning(err))
|
||||
}
|
||||
}
|
||||
}),
|
||||
),
|
||||
]);
|
||||
} else {
|
||||
final_task = reading_additional_task;
|
||||
@@ -153,7 +158,7 @@ impl ScreenState {
|
||||
DataLoaded(map)
|
||||
}
|
||||
|
||||
async fn load_web_backup(string: String) -> Result<bool, Error> {
|
||||
async fn load_web_backup(string: String) -> Result<bool, NotificationData> {
|
||||
let local = get_local_version().await;
|
||||
let web = get_web_version(string.as_str()).await?;
|
||||
println!("{} {}", local, web);
|
||||
@@ -198,7 +203,7 @@ impl ScreenState {
|
||||
if let Notification(message) = message {
|
||||
return self.notification_manager.update(message);
|
||||
}
|
||||
|
||||
|
||||
if let PushNotification(notification) = &message {
|
||||
return self.notification_manager.push(notification.clone())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user