Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(desktop): add manual check for updates in settings
Richie McIlroyac139d1689f4
diff --git a/apps/desktop/src/routes/(window-chrome)/settings.tsx b/apps/desktop/src/routes/(window-chrome)/settings.tsxindex df6e6b3f6..0c6109973 100644--- a/apps/desktop/src/routes/(window-chrome)/settings.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings.tsx@@ -1,9 +1,11 @@import { Button } from "@cap/ui-solid";-import { A, type RouteSectionProps } from "@solidjs/router";+import { A, type RouteSectionProps, useNavigate } from "@solidjs/router";import { getVersion } from "@tauri-apps/api/app";+import * as dialog from "@tauri-apps/plugin-dialog";import * as shell from "@tauri-apps/plugin-shell";+import { check } from "@tauri-apps/plugin-updater";import "@total-typescript/ts-reset/filter-boolean";-import { createResource, For, Show, Suspense } from "solid-js";+import { createResource, createSignal, For, Show, Suspense } from "solid-js";import { CapErrorBoundary } from "~/components/CapErrorBoundary";import { SignInButton } from "~/components/SignInButton";@@ -11,8 +13,10 @@ import { authStore } from "~/store";import { trackEvent } from "~/utils/analytics";export default function Settings(props: RouteSectionProps) {+ const navigate = useNavigate();const auth = authStore.createQuery();const [version] = createResource(() => getVersion());+ const [isCheckingForUpdates, setIsCheckingForUpdates] = createSignal(false);const handleAuth = async () => {if (auth.data) {@@ -21,6 +25,40 @@ export default function Settings(props: RouteSectionProps) {}};+ const checkForUpdates = async () => {+ setIsCheckingForUpdates(true);++ try {+ const update = await check();++ if (!update) {+ await dialog.message(+ "You're already using the latest version of Cap.",+ {+ title: "No Update Available",+ kind: "info",+ },+ );+ return;+ }++ const shouldUpdate = await dialog.confirm(+ `Version ${update.version} of Cap is available, would you like to install it?`,+ { title: "Update Cap", okLabel: "Update", cancelLabel: "Ignore" },+ );++ if (shouldUpdate) navigate("/update");+ } catch (e) {+ console.error("Failed to check for updates:", e);+ await dialog.message(+ "Unable to check for updates. Please download the latest version manually from cap.so/download. Your data will not be lost.\n\nIf this issue persists, please contact support.",+ { title: "Update Error", kind: "error" },+ );+ } finally {+ setIsCheckingForUpdates(false);+ }+ };+return (<div class="flex-1 flex flex-row divide-x divide-gray-3 text-[0.875rem] leading-5 overflow-y-hidden"><div class="flex flex-col h-full bg-gray-2">@@ -98,13 +136,27 @@ export default function Settings(props: RouteSectionProps) {{(v) => (<div class="mb-2 text-xs text-gray-11 flex flex-col items-start gap-0.5"><span>v{v()}</span>- <button- type="button"- class="text-gray-11 hover:text-gray-12 underline transition-colors"- onClick={() => shell.open("https://cap.so/download/versions")}- >- View previous versions- </button>+ <div class="flex flex-col items-start gap-0.5">+ <button+ type="button"+ class="text-gray-11 hover:text-gray-12 underline transition-colors"+ onClick={() =>+ shell.open("https://cap.so/download/versions")+ }+ >+ View previous versions+ </button>+ <button+ type="button"+ class="text-gray-11 hover:text-gray-12 underline transition-colors disabled:cursor-default disabled:opacity-50 disabled:hover:text-gray-11"+ disabled={isCheckingForUpdates()}+ onClick={checkForUpdates}+ >+ {isCheckingForUpdates()+ ? "Checking..."+ : "Check for updates"}+ </button>+ </div></div>)}</Show>