Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AppHandle::fetch_all_data_store_identifiers and AppHandle::remove_data_store #12900

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/tauri-runtime-wry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ wry = { version = "0.50.3", default-features = false, features = [
"protocol",
"os-webview",
"linux-body",
] }
], git = "https://github.com/Simon-Laux/wry", branch = "datastore-improvements" }
tao = { version = "0.32.2", default-features = false, features = ["rwh_06"] }
tauri-runtime = { version = "2.4.0", path = "../tauri-runtime" }
tauri-utils = { version = "2.2.0", path = "../tauri-utils" }
Expand Down
2 changes: 2 additions & 0 deletions crates/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4630,3 +4630,5 @@ fn inner_size(
) -> TaoPhysicalSize<u32> {
window.inner_size()
}

pub use wry::{fetch_all_data_store_identifiers, remove_data_store};
33 changes: 33 additions & 0 deletions crates/tauri/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use tauri_utils::{assets::AssetsIter, PackageInfo};

use std::{
borrow::Cow,
cell::Cell,
collections::HashMap,
fmt,
sync::{mpsc::Sender, Arc, MutexGuard},
Expand Down Expand Up @@ -370,6 +371,38 @@ impl AppHandle<crate::Wry> {
}
}

#[cfg(all(feature = "wry", target_vendor = "apple"))]
impl AppHandle<crate::Wry> {
/// Fetches all Data Store Indentifiers by this app
///
/// Needs to be called from Main Thread
pub async fn fetch_all_data_store_identifiers() -> Result<Vec<[u8; 16]>, anyhow::Error> {
let (tx, rx) = tokio::sync::oneshot::channel::<Vec<[u8; 16]>>();
let cell: Cell<Option<_>> = Cell::new(Some(tx));
// does this need to be called on seperate thread?
tauri_runtime_wry::fetch_all_data_store_identifiers(move |ids| {
if let Some(tx) = cell.take() {
let _ = tx.send(ids);
}
})?;
Ok(rx.await?)
}
/// Deletes a Data Store of this app
///
/// Needs to be called from Main Thread
pub async fn remove_data_store(uuid: [u8; 16]) -> Result<(), anyhow::Error> {
let (tx, rx) = tokio::sync::oneshot::channel::<Result<(), tauri_runtime_wry::wry::Error>>();
let cell: Cell<Option<_>> = Cell::new(Some(tx));
// does this need to be called on seperate thread?
tauri_runtime_wry::remove_data_store(&uuid, move |result| {
if let Some(tx) = cell.take() {
let _ = tx.send(result);
}
})?;
Ok(rx.await??)
}
}

impl<R: Runtime> Clone for AppHandle<R> {
fn clone(&self) -> Self {
Self {
Expand Down