Reapply "refactor(app): reduce tech debt by eliminating wry fork" (#4555)

* Reapply "refactor(app): reduce tech debt by eliminating `wry` fork (#4500)"

This reverts commit 2535156dac.

* test: temporarily replace ad link by something with sound

* Revert "test: temporarily replace ad link by something with sound"

This reverts commit 74bb7eecb7cc7b17ccfd6b2e20c24eeec38ac363.

* Reapply "test: temporarily replace ad link by something with sound"

This reverts commit f1b0e9f2c4a30f789099048e98ffa91ff376f571.

* test: also disable ads init muting script for good measure

* Revert "test: also disable ads init muting script for good measure"

This reverts commit 4ac7a81e1780f13c976d033c420bfe1d5db9c298.

* Revert "Reapply "test: temporarily replace ad link by something with sound""

This reverts commit c5f1b9f242f5c7f56b40f21b586e8b484c7eb3c5.
This commit is contained in:
Alejandro González
2025-10-15 12:24:32 +02:00
committed by GitHub
parent 2535156dac
commit 7fa442fb28
4 changed files with 30 additions and 16 deletions

View File

@@ -79,7 +79,6 @@ pub async fn init_ads_window<R: Runtime>(
override_shown: bool,
) -> crate::api::Result<()> {
use tauri::WebviewUrl;
const LINK_SCRIPT: &str = include_str!("ads-init.js");
let state = app.state::<RwLock<AdsState>>();
let mut state = state.write().await;
@@ -102,25 +101,42 @@ pub async fn init_ads_window<R: Runtime>(
webview.set_position(PhysicalPosition::new(-1000, -1000));
}
} else if let Some(window) = app.get_window("main") {
let _ = window.add_child(
let webview = window.add_child(
tauri::webview::WebviewBuilder::new(
"ads-window",
WebviewUrl::External(
AD_LINK.parse().unwrap(),
),
)
.initialization_script(LINK_SCRIPT)
// .initialization_script_for_main_only(LINK_SCRIPT, false)
.user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36")
.zoom_hotkeys_enabled(false)
.transparent(true),
.initialization_script_for_all_frames(include_str!("ads-init.js"))
.user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36")
.zoom_hotkeys_enabled(false)
.transparent(true)
.on_new_window(|_, _| tauri::webview::NewWindowResponse::Deny),
if state.shown {
position
} else {
PhysicalPosition::new(-1000.0, -1000.0)
},
size,
);
)?;
webview.with_webview(#[allow(unused_variables)] |webview2| {
#[cfg(windows)]
{
use webview2_com::Microsoft::Web::WebView2::Win32::ICoreWebView2_8;
use windows_core::Interface;
let webview2_controller = webview2.controller();
let Ok(webview2_8) = unsafe { webview2_controller.CoreWebView2() }
.and_then(|core_webview2| core_webview2.cast::<ICoreWebView2_8>())
else {
return;
};
unsafe { webview2_8.SetIsMuted(true) }.ok();
}
})?;
}
}