From eaf9bda0776c672302c861b4c6361cf75eab3aaa Mon Sep 17 00:00:00 2001 From: reya Date: Tue, 30 Jan 2024 13:16:39 +0700 Subject: [PATCH] feat: add new update notify to navigation --- packages/icons/index.ts | 1 + packages/icons/src/arrowUpSquare.tsx | 24 ++++++++++++++++ packages/ui/src/navigation.tsx | 43 +++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 packages/icons/src/arrowUpSquare.tsx diff --git a/packages/icons/index.ts b/packages/icons/index.ts index 96c9d5640..1fb805ef4 100644 --- a/packages/icons/index.ts +++ b/packages/icons/index.ts @@ -112,3 +112,4 @@ export * from "./src/editInterest"; export * from "./src/newColumn"; export * from "./src/searchFilled"; export * from "./src/arrowUp"; +export * from "./src/arrowUpSquare"; diff --git a/packages/icons/src/arrowUpSquare.tsx b/packages/icons/src/arrowUpSquare.tsx new file mode 100644 index 000000000..d035e0875 --- /dev/null +++ b/packages/icons/src/arrowUpSquare.tsx @@ -0,0 +1,24 @@ +import { SVGProps } from "react"; + +export function ArrowUpSquareIcon( + props: JSX.IntrinsicAttributes & SVGProps, +) { + return ( + + + + ); +} diff --git a/packages/ui/src/navigation.tsx b/packages/ui/src/navigation.tsx index b89d0eea3..5367ec803 100644 --- a/packages/ui/src/navigation.tsx +++ b/packages/ui/src/navigation.tsx @@ -1,7 +1,7 @@ import { + ArrowUpSquareIcon, BellFilledIcon, BellIcon, - ComposeFilledIcon, DepotFilledIcon, DepotIcon, HomeFilledIcon, @@ -13,7 +13,11 @@ import { SettingsIcon, } from "@lume/icons"; import { cn, editorAtom, searchAtom } from "@lume/utils"; +import { confirm } from "@tauri-apps/plugin-dialog"; +import { relaunch } from "@tauri-apps/plugin-process"; +import { Update, check } from "@tauri-apps/plugin-updater"; import { useAtom } from "jotai"; +import { useEffect, useState } from "react"; import { useHotkeys } from "react-hotkeys-hook"; import { NavLink } from "react-router-dom"; import { ActiveAccount } from "./account/active"; @@ -22,10 +26,33 @@ import { UnreadActivity } from "./unread"; export function Navigation() { const [isEditorOpen, setIsEditorOpen] = useAtom(editorAtom); const [search, setSearch] = useAtom(searchAtom); + const [update, setUpdate] = useState(null); // shortcut for editor useHotkeys("meta+n", () => setIsEditorOpen((state) => !state), []); + const installNewUpdate = async () => { + if (!update) return; + + const yes = await confirm(update.body, { + title: `v${update.version} is available`, + type: "info", + }); + + if (yes) { + await update.downloadAndInstall(); + await relaunch(); + } + }; + + useEffect(() => { + async function checkNewUpdate() { + const newVersion = await check(); + setUpdate(newVersion); + } + checkNewUpdate(); + }, []); + return (
+ {update ? ( + + ) : null}