From 5928a14b8d4469967ffa8c92909424f981d65bc6 Mon Sep 17 00:00:00 2001 From: "don.cryptus" Date: Thu, 5 Oct 2023 00:30:05 +0200 Subject: [PATCH] easy --- src/@types/images.d.ts | 4 ++++ src/components/pages/app/Clipboards.tsx | 19 ++++++++++++------- src/components/pages/app/RecentClipboards.tsx | 2 +- .../pages/app/StarredClipboards.tsx | 2 +- src/index.tsx | 18 ++++++++---------- src/settings.tsx | 2 +- src/store/HotkeyStore.ts | 6 ++---- src/store/SettingsStore.ts | 2 +- vite.config.ts | 8 ++++---- 9 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 src/@types/images.d.ts diff --git a/src/@types/images.d.ts b/src/@types/images.d.ts new file mode 100644 index 00000000..0357e4f1 --- /dev/null +++ b/src/@types/images.d.ts @@ -0,0 +1,4 @@ +declare module "*.png"; +declare module "*.svg"; +declare module "*.jpeg"; +declare module "*.jpg"; diff --git a/src/components/pages/app/Clipboards.tsx b/src/components/pages/app/Clipboards.tsx index 6e6d6a54..e60a0029 100644 --- a/src/components/pages/app/Clipboards.tsx +++ b/src/components/pages/app/Clipboards.tsx @@ -63,7 +63,9 @@ export const Clipboards: Component = ({}) => { star: !clipboard.star, }); setClipboards((prev) => - prev.map((o) => (o.id === id ? { ...o, star: !clipboard.star } : o)) + prev.map((o) => + o.id === id ? { ...o, star: !clipboard.star } : o, + ), ); }} class={`${ @@ -133,7 +135,7 @@ export const Clipboards: Component = ({}) => { ? URL.createObjectURL( new Blob([new Uint8Array(blob)], { type: "image/png", - }) + }), ) : null; @@ -145,10 +147,13 @@ export const Clipboards: Component = ({}) => { e.stopPropagation(); if (e.detail === 1) { - dbClickTimer = setTimeout(async () => { - await invoke("copy_clipboard", { id }); - removeAllHotkeyListeners(); - }, clipboard.type === "image" ? 200 : 0); + dbClickTimer = setTimeout( + async () => { + await invoke("copy_clipboard", { id }); + removeAllHotkeyListeners(); + }, + clipboard.type === "image" ? 200 : 0, + ); } }} onDblClick={async (e) => { @@ -187,7 +192,7 @@ export const Clipboards: Component = ({}) => { class="relative max-h-64 w-full" alt={`${width}x${height} ${size}`} title={`${width}x${height} ${formatBytes( - Number(size || "0") + Number(size || "0"), )}`} /> ) : ( diff --git a/src/components/pages/app/RecentClipboards.tsx b/src/components/pages/app/RecentClipboards.tsx index 34873054..4e61349a 100644 --- a/src/components/pages/app/RecentClipboards.tsx +++ b/src/components/pages/app/RecentClipboards.tsx @@ -1,4 +1,4 @@ -import { Component, createEffect, onMount } from "solid-js"; +import { Component, onMount } from "solid-js"; import ClipboardStore from "../../../store/ClipboardStore"; import { Clipboards } from "./Clipboards"; diff --git a/src/components/pages/app/StarredClipboards.tsx b/src/components/pages/app/StarredClipboards.tsx index 03246ef8..f38b8c2b 100644 --- a/src/components/pages/app/StarredClipboards.tsx +++ b/src/components/pages/app/StarredClipboards.tsx @@ -1,4 +1,4 @@ -import { Component, createEffect, onMount } from "solid-js"; +import { Component, onMount } from "solid-js"; import ClipboardStore, { initialWhere } from "../../../store/ClipboardStore"; import { Clipboards } from "./Clipboards"; diff --git a/src/index.tsx b/src/index.tsx index 185641c5..1c9c2311 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,6 +1,4 @@ -import { invoke } from "@tauri-apps/api"; import { listen } from "@tauri-apps/api/event"; -import { appWindow } from "@tauri-apps/api/window"; import { createResource, onMount } from "solid-js"; import { render } from "solid-js/web"; import App from "./components/pages/app/App"; @@ -17,17 +15,17 @@ const Index = () => { onMount(async () => { setGlobalHotkeyEvent(true); - const focus = await appWindow.onFocusChanged( - async ({ payload }) => - !payload && (await invoke("window_display_toggle")), - ); + // const focus = await appWindow.onFocusChanged( + // async ({ payload }) => + // !payload && (await invoke("window_display_toggle")), + // ); const init_listener = await listen("init_listener", init); - setTimeout(async () => { - await invoke("stop_hotkeys"); - setGlobalHotkeyEvent(false); - }, 5000); + // setTimeout(async () => { + // await invoke("stop_hotkeys"); + // setGlobalHotkeyEvent(false); + // }, 5000); return async () => { init_listener(); diff --git a/src/settings.tsx b/src/settings.tsx index e0480554..1c11a9f5 100644 --- a/src/settings.tsx +++ b/src/settings.tsx @@ -12,7 +12,7 @@ const Settings = () => { const { getCurrentTab, initSettings } = SettingsStore; const { initHotkeys } = HotkeyStore; - initHotkeys(false); + initHotkeys(); initSettings(); return ( diff --git a/src/store/HotkeyStore.ts b/src/store/HotkeyStore.ts index 5d7d195a..97b0bee6 100644 --- a/src/store/HotkeyStore.ts +++ b/src/store/HotkeyStore.ts @@ -1,7 +1,7 @@ import { invoke } from "@tauri-apps/api"; import { createRoot, createSignal } from "solid-js"; import { Hotkey, HotkeyEvent } from "../@types"; -import { parseShortcut, registerHotkeys } from "../utils/hotkeyRegister"; +import { parseShortcut } from "../utils/hotkeyRegister"; function createHotkeyStore() { const [globalHotkeyEvent, setGlobalHotkeyEvent] = createSignal(true); @@ -20,7 +20,7 @@ function createHotkeyStore() { const getHotkey = (event: HotkeyEvent) => hotkeys().find((h) => h.event === event); - const initHotkeys = async (reg: boolean | undefined = false) => { + const initHotkeys = async () => { // await unregisterAll(); const hotkeys = (await invoke("get_hotkeys")).map((h) => ({ @@ -41,8 +41,6 @@ function createHotkeyStore() { // invoke("window_display_toggle"); // }).catch(() => {}); // } - - if (reg) await registerHotkeys(hotkeys); }; return { diff --git a/src/store/SettingsStore.ts b/src/store/SettingsStore.ts index 41225305..cfa6c14e 100644 --- a/src/store/SettingsStore.ts +++ b/src/store/SettingsStore.ts @@ -62,7 +62,7 @@ function createSettingsStore() { const init = async () => { await initSettings(); - // HotkeyStore.initHotkeys(true); + HotkeyStore.initHotkeys(); darkMode(); }; diff --git a/vite.config.ts b/vite.config.ts index 8fc7b982..256dbab8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,15 +1,15 @@ import { defineConfig } from "vite"; +import checker from "vite-plugin-checker"; import solidPlugin from "vite-plugin-solid"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [ solidPlugin(), - // checker({ - // typescript: true, - // }), + checker({ + typescript: true, + }), ], - // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` // // 1. prevent vite from obscuring rust errors