Skip to content

Commit dac1db3

Browse files
authored
fix(tauri) notification body optional, requestPermission() regression, closes #793 (#844)
* fix(tauri) notification body optional, title required * fix(tauri) regression on requestPermission()
1 parent 0591f1f commit dac1db3

5 files changed

Lines changed: 21 additions & 10 deletions

File tree

.changes/notificaiton-fix.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri.js": patch
3+
"tauri": patch
4+
---
5+
6+
The notification's `body` is now optional, closes #793.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Fixes a regression on the storage of requestPermission response.
6+
ß

cli/tauri.js/templates/tauri.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ switch (navigator.platform) {
220220
return window.__TAURI__.promisified({
221221
cmd: 'notification',
222222
options: typeof options === 'string' ? {
223-
body: options
223+
title: options
224224
} : options
225225
})
226226
}

tauri/src/endpoints/cmd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ pub struct SaveDialogOptions {
5353
#[derive(Deserialize)]
5454
pub struct NotificationOptions {
5555
/// The notification title.
56-
pub title: Option<String>,
56+
pub title: String,
5757
/// The notification body.
58-
pub body: String,
58+
pub body: Option<String>,
5959
/// The notification icon.
6060
pub icon: Option<String>,
6161
}

tauri/src/endpoints/notification.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ pub fn send<T: 'static>(
1111
crate::execute_promise(
1212
webview,
1313
move || {
14-
let mut notification = tauri_api::notification::Notification::new();
15-
notification = notification.body(options.body);
16-
if let Some(title) = options.title {
17-
notification = notification.title(title);
14+
let mut notification = tauri_api::notification::Notification::new().title(options.title);
15+
if let Some(body) = options.body {
16+
notification = notification.body(body);
1817
}
1918
if let Some(icon) = options.icon {
2019
notification = notification.icon(icon);
@@ -56,8 +55,8 @@ pub fn request_permission<T: 'static>(
5655
webview,
5756
move || {
5857
let mut settings = crate::settings::read_settings()?;
59-
let granted = r#""granted""#.to_string();
60-
let denied = r#""denied""#.to_string();
58+
let granted = "granted".to_string();
59+
let denied = "denied".to_string();
6160
if let Some(allow_notification) = settings.allow_notification {
6261
return Ok(if allow_notification { granted } else { denied });
6362
}
@@ -76,7 +75,7 @@ pub fn request_permission<T: 'static>(
7675
crate::settings::write_settings(settings)?;
7776
Ok(denied)
7877
}
79-
_ => Ok(r#""default""#.to_string()),
78+
_ => Ok("default".to_string()),
8079
}
8180
},
8281
callback,

0 commit comments

Comments
 (0)