Skip to content

Commit c862e56

Browse files
authored
Merge pull request #1171 from tonymushah/1148-notify-when-the-toast-is-not-visible
1148 notify when the toast is not visible
2 parents 08f36f8 + d97fad0 commit c862e56

File tree

27 files changed

+357
-133
lines changed

27 files changed

+357
-133
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"@tauri-apps/api": "^2.9.0",
9595
"@tauri-apps/plugin-clipboard-manager": "^2.3.2",
9696
"@tauri-apps/plugin-dialog": "^2.4.2",
97+
"@tauri-apps/plugin-notification": "^2.3.3",
9798
"@tauri-apps/plugin-opener": "^2.5.2",
9899
"@urql/svelte": "^5.0.0",
99100
"core-js": "^3.46.0",

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "special-eureka"
3-
version = "0.2.2-1"
3+
version = "0.2.2-2"
44
description = "a manga reader desktop app build with tauri"
55
authors = ["tonymushah"]
66
license = ""

src-tauri/core/capabilities/mains.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
"core:webview:allow-create-webview-window",
3232
"dialog:allow-open",
3333
"dialog:allow-save",
34-
"opener:allow-reveal-item-in-dir"
34+
"opener:allow-reveal-item-in-dir",
35+
"notification:allow-notify",
36+
"notification:allow-is-permission-granted",
37+
"notification:deny-request-permission"
3538
]
3639
}

src-tauri/mangadex/src/mutation/user_option.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ use crate::{
3131
MangaDexTheme,
3232
profiles::{ThemeProfileDefaultKey, ThemeProfileEntry, ThemeProfiles},
3333
},
34+
toast_notify::ToastNotifyStore,
3435
},
3536
},
3637
},
3738
utils::{get_app_handle_from_async_graphql, traits_utils::MangadexAsyncGraphQLContextExt},
3839
};
3940
use async_graphql::{Context, Object};
40-
use mangadex_api_types_rust::Language;
4141

4242
use crate::{
4343
store::types::{
@@ -49,7 +49,6 @@ use crate::{
4949
manga_list_style::{MangaListStyle, MangaListStyleStore},
5050
reading_mode::{ReadingMode, ReadingModeStore},
5151
},
52-
structs::chapter_language::ChapterLanguagesStore,
5352
},
5453
utils::{get_store, get_watches_from_graphql_context, watch::SendData},
5554
};
@@ -99,19 +98,6 @@ impl UserOptionMutations {
9998
watches.sidebar_direction.send_data(inner)?;
10099
Ok(SidebarDirectionStore::extract_from_store(&store_write)?.into())
101100
}
102-
pub async fn set_chapter_languages(
103-
&self,
104-
ctx: &Context<'_>,
105-
languages: Vec<Language>,
106-
) -> Result<Vec<Language>> {
107-
let store = get_store::<tauri::Wry>(ctx)?;
108-
let store_write = store.write().await;
109-
let watches = get_watches_from_graphql_context::<tauri::Wry>(ctx)?;
110-
let inner = ChapterLanguagesStore::from(languages);
111-
inner.insert_and_save(&store_write)?;
112-
watches.chapter_languages.send_data(inner)?;
113-
Ok(ChapterLanguagesStore::extract_from_store(&store_write)?.into())
114-
}
115101
pub async fn set_image_fit(&self, ctx: &Context<'_>, image_fit: ImageFit) -> Result<ImageFit> {
116102
let store = get_store::<tauri::Wry>(ctx)?;
117103
let store_write = store.write().await;
@@ -444,4 +430,17 @@ impl UserOptionMutations {
444430
watches.content_profile_warning.send_data(*store)?;
445431
Ok(*store)
446432
}
433+
pub async fn set_toast_notify(
434+
&self,
435+
ctx: &Context<'_>,
436+
notify: bool,
437+
) -> crate::Result<bool, crate::error::ErrorWrapper> {
438+
let app = ctx.get_app_handle::<tauri::Wry>()?;
439+
let watches = get_watches_from_graphql_context::<tauri::Wry>(ctx)?;
440+
let mut store = app.extract::<ToastNotifyStore>().await?;
441+
*store = notify;
442+
app.insert_and_save(&store).await?;
443+
watches.toast_notify.send_data(*store)?;
444+
Ok(*store)
445+
}
447446
}

src-tauri/mangadex/src/plugin_setup/init_watches_states.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::{
1515
reading_mode::ReadingModeStore,
1616
},
1717
structs::{
18-
chapter_language::ChapterLanguagesStore,
1918
chapter_layout::ChapterLayoutStore,
2019
client_info::ClientInfoStore,
2120
content::profiles::{ContentProfileDefaultKey, ContentProfiles},
@@ -24,6 +23,7 @@ use crate::{
2423
longstrip_image_width::LongstripImageWidthStore,
2524
page_limit::PageLimitStore,
2625
theme::profiles::{ThemeProfileDefaultKey, ThemeProfiles},
26+
toast_notify::ToastNotifyStore,
2727
},
2828
},
2929
utils::watch::{SendData, Watches},
@@ -43,7 +43,6 @@ macro_rules! setup_watch {
4343

4444
setup_watch! {
4545
reading_mode <= ReadingModeStore,
46-
chapter_languages <= ChapterLanguagesStore,
4746
page_direction <= ReadingDirectionStore,
4847
sidebar_direction <= SidebarDirectionStore,
4948
image_fit <= ImageFitStore,
@@ -62,6 +61,7 @@ setup_watch! {
6261
force_port_443 <= ForcePort443Store,
6362
content_profile_blur <= ContentProfileBlurStore,
6463
content_profile_warning <= ContentProfileWarningModeStore,
64+
toast_notify <= ToastNotifyStore,
6565
}
6666

6767
#[cfg_attr(feature = "hotpath", hotpath::measure)]

src-tauri/mangadex/src/query/user_option.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
utils::traits_utils::{MangadexAsyncGraphQLContextExt, MangadexTauriManagerExt},
2020
};
2121
use async_graphql::{Context, Object};
22-
use mangadex_api_types_rust::{Language, MangaDexDateTime};
22+
use mangadex_api_types_rust::MangaDexDateTime;
2323
use tokio_stream::StreamExt;
2424

2525
use crate::{
@@ -31,7 +31,6 @@ use crate::{
3131
},
3232
reading_mode::{ReadingMode, ReadingModeStore},
3333
},
34-
structs::chapter_language::ChapterLanguagesStore,
3534
},
3635
utils::{get_store, get_watches_from_graphql_context, watch::SendData},
3736
};
@@ -66,14 +65,6 @@ impl UserOptionQueries {
6665
let _ = watches.sidebar_direction.send_data(sds.clone());
6766
Ok(sds.into())
6867
}
69-
pub async fn get_chapter_languages(&self, ctx: &Context<'_>) -> Result<Vec<Language>> {
70-
let store = get_store::<tauri::Wry>(ctx)?;
71-
let store_read = store.read().await;
72-
let watches = get_watches_from_graphql_context::<tauri::Wry>(ctx)?;
73-
let cls = ChapterLanguagesStore::extract_from_store(store_read.deref())?;
74-
let _ = watches.chapter_languages.send_data(cls.clone());
75-
Ok(cls.into())
76-
}
7768
pub async fn get_default_content_profile(&self, ctx: &Context<'_>) -> Result<ContentProfile> {
7869
let stream = UserOptionSubscriptions
7970
.listen_to_content_profile_default(ctx)

src-tauri/mangadex/src/store.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ use self::{
3232
reading_mode::ReadingModeStore,
3333
},
3434
structs::{
35-
chapter_language::ChapterLanguagesStore, chapter_layout::ChapterLayoutStore,
36-
client_info::ClientInfoStore, page_limit::PageLimitStore,
37-
refresh_token::RefreshTokenStore,
35+
chapter_layout::ChapterLayoutStore, client_info::ClientInfoStore,
36+
page_limit::PageLimitStore, refresh_token::RefreshTokenStore,
37+
toast_notify::ToastNotifyStore,
3838
},
3939
},
4040
};
@@ -62,7 +62,6 @@ get_store_builder! {
6262
ReadingDirectionStore,
6363
ReadingModeStore,
6464
SidebarDirectionStore,
65-
ChapterLanguagesStore,
6665
ImageFitStore,
6766
LongstripImageWidthStore,
6867
MangaListStyleStore,
@@ -79,6 +78,7 @@ get_store_builder! {
7978
ForcePort443Store,
8079
ContentProfileBlurStore,
8180
ContentProfileWarningModeStore,
81+
ToastNotifyStore,
8282
}
8383

8484
// [x] refactor into a macro!

src-tauri/mangadex/src/store/keys.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ pub const SIDEBAR_DIRECTION: &str = "sidebar_direction";
1010

1111
pub const READING_MODE: &str = "reading_mode";
1212

13-
pub const CHAPTER_LANGUAGES: &str = "chapter_languages";
14-
1513
pub const IMAGE_FIT: &str = "image_fit";
1614

1715
pub const LONGSTRIP_IMAGE_WIDTH: &str = "longstrip_image_width";
@@ -43,3 +41,5 @@ pub const FORCE_443: &str = "force_443";
4341
pub const CONTENT_PROFILE_WARNING_MODE: &str = "content_profile_warning_mode";
4442

4543
pub const CONTENT_PROFILE_BLUR: &str = "content_profile_blur";
44+
45+
pub const TOAST_NOTIFY: &str = "toast_notify";

0 commit comments

Comments
 (0)