fix: use webview's resources table (#1191)

* fix: use webview's resources table

* fix clipboard into_img usage

* fix mobile
This commit is contained in:
Amr Bashir
2024-04-18 03:19:24 +02:00
committed by GitHub
parent 8638740223
commit e3d41f4011
13 changed files with 152 additions and 102 deletions
+6 -5
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use tauri::{command, AppHandle, Manager, ResourceId, Runtime, State};
use tauri::{command, AppHandle, Manager, ResourceId, Runtime, State, Webview};
use crate::{ClipKind, Clipboard, ClipboardContents, Result};
@@ -17,11 +17,12 @@ pub(crate) async fn write_text<R: Runtime>(
#[command]
pub(crate) async fn write_image<R: Runtime>(
_app: AppHandle<R>,
webview: Webview<R>,
clipboard: State<'_, Clipboard<R>>,
data: ClipKind,
) -> Result<()> {
clipboard.write_image(data)
let resources_table = webview.resources_table();
clipboard.write_image_inner(data, &resources_table)
}
#[command]
@@ -34,11 +35,11 @@ pub(crate) async fn read_text<R: Runtime>(
#[command]
pub(crate) async fn read_image<R: Runtime>(
app: AppHandle<R>,
webview: Webview<R>,
clipboard: State<'_, Clipboard<R>>,
) -> Result<ResourceId> {
let image = clipboard.read_image()?.to_owned();
let mut resources_table = app.resources_table();
let mut resources_table = webview.resources_table();
let rid = resources_table.add(image);
Ok(rid)
}