Skip to content

Commit

Permalink
easy
Browse files Browse the repository at this point in the history
  • Loading branch information
0-don committed Sep 27, 2023
1 parent ad0638c commit 1a05f9f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src-tauri/src/utils/clipboard/clipboard_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl ClipboardHelper {
&& last_clipboard.blob.is_some()
&& image.as_ref().unwrap() == last_clipboard.blob.as_ref().unwrap()
{

return true;
}

Expand Down
35 changes: 22 additions & 13 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,30 @@ const Index = () => {
}
});

listen<Clips>("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<Clips>(
"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 <App />;
Expand Down
7 changes: 6 additions & 1 deletion src/utils/hotkeyRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 1a05f9f

Please sign in to comment.