diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 49549706..9a670357 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -49,8 +49,8 @@ custom-protocol = ["tauri/custom-protocol"] [profile.release] -panic = "abort" -codegen-units = 1 -lto = true -opt-level = "s" -strip = true +# panic = "abort" +# codegen-units = 1 +# lto = true +# opt-level = "s" +# strip = true diff --git a/src-tauri/src/utils/clipboard/clipboard_helper.rs b/src-tauri/src/utils/clipboard/clipboard_helper.rs index 11740887..d38e4677 100644 --- a/src-tauri/src/utils/clipboard/clipboard_helper.rs +++ b/src-tauri/src/utils/clipboard/clipboard_helper.rs @@ -105,6 +105,7 @@ impl ClipboardHelper { && last_clipboard.blob.is_some() && image.as_ref().unwrap() == last_clipboard.blob.as_ref().unwrap() { + return true; } diff --git a/src/index.tsx b/src/index.tsx index 24ab9d28..bf156b2c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -26,21 +26,30 @@ const Index = () => { } }); - listen("clipboard_listener", ({ payload }) => { - settings()?.notification && - sendNotification({ - title: `New ${payload.type}`, - body: "Copied to clipboard", - }); - setClipboards((prev) => [payload, ...prev]); - }); - - listen("init_listener", init); - - listen("init_hotkeys_listener", () => { + const clipboard_listener = await listen( + "clipboard_listener", + ({ payload }) => { + settings()?.notification && + sendNotification({ + title: `New ${payload.type}`, + body: "Copied to clipboard", + }); + setClipboards((prev) => [payload, ...prev]); + }, + ); + + const init_listener = await listen("init_listener", init); + + const init_hotkeys_listener = await listen("init_hotkeys_listener", () => { console.log("init_hotkeys_listener"); - initHotkeys(true); + // initHotkeys(true); }); + + return async () => { + // clipboard_listener(); + // init_listener(); + init_hotkeys_listener(); + }; }); return ; diff --git a/src/utils/hotkeyRegister.ts b/src/utils/hotkeyRegister.ts index cfdb5db4..0e15b2cc 100644 --- a/src/utils/hotkeyRegister.ts +++ b/src/utils/hotkeyRegister.ts @@ -41,13 +41,18 @@ export async function registerHotkeys(hotkeys: Hotkey[]) { // Display and hide the app window const windowHotkey = hotkeys.find((h) => h.event === "window_display_toggle"); if (windowHotkey?.status && !(await isRegistered(windowHotkey.shortcut))) { + console.log("registering", await isRegistered(windowHotkey.shortcut)); try { await register(windowHotkey.shortcut, () => { + console.log("registered"); updateSidebarIcons("Recent Clipboards"); invoke("window_display_toggle"); }); - } catch (_) {} + } catch (_) { + console.log("error"); + registerHotkeys(hotkeys); + } } // const typeHotkey = hotkeys.find((h) => h.event === "type_clipboard");