fix: missing check for update

This commit is contained in:
reya 2024-11-03 13:49:19 +07:00
parent cd6ba5884f
commit 85fa1e2359
9 changed files with 50 additions and 87 deletions

View File

@ -4,10 +4,7 @@
"enabled": true "enabled": true
}, },
"files": { "files": {
"ignore": [ "ignore": ["./src/routes.gen.ts", "./src/commands.gen.ts"]
"./src/routes.gen.ts",
"./src/commands.gen.ts"
]
}, },
"linter": { "linter": {
"enabled": true, "enabled": true,

View File

@ -2,13 +2,8 @@
"$schema": "../gen/schemas/desktop-schema.json", "$schema": "../gen/schemas/desktop-schema.json",
"identifier": "window", "identifier": "window",
"description": "Capability for the desktop", "description": "Capability for the desktop",
"platforms": [ "platforms": ["macOS", "windows"],
"macOS", "windows": ["*"],
"windows"
],
"windows": [
"*"
],
"permissions": [ "permissions": [
"core:path:default", "core:path:default",
"core:event:default", "core:event:default",

View File

@ -39,10 +39,7 @@
"targets": "all", "targets": "all",
"active": true, "active": true,
"category": "SocialNetworking", "category": "SocialNetworking",
"resources": [ "resources": ["resources/*", "locales/*"],
"resources/*",
"locales/*"
],
"icon": [ "icon": [
"icons/32x32.png", "icons/32x32.png",
"icons/128x128.png", "icons/128x128.png",

View File

@ -13,9 +13,7 @@
"hiddenTitle": true, "hiddenTitle": true,
"transparent": true, "transparent": true,
"windowEffects": { "windowEffects": {
"effects": [ "effects": ["underWindowBackground"]
"underWindowBackground"
]
} }
} }
] ]

View File

@ -3,11 +3,9 @@ import type {
MaybePromise, MaybePromise,
PersistedQuery, PersistedQuery,
} from "@tanstack/query-persist-client-core"; } from "@tanstack/query-persist-client-core";
import { ask, message, open } from "@tauri-apps/plugin-dialog"; import { open } from "@tauri-apps/plugin-dialog";
import { readFile } from "@tauri-apps/plugin-fs"; import { readFile } from "@tauri-apps/plugin-fs";
import { relaunch } from "@tauri-apps/plugin-process";
import type { Store as TauriStore } from "@tauri-apps/plugin-store"; import type { Store as TauriStore } from "@tauri-apps/plugin-store";
import { check } from "@tauri-apps/plugin-updater";
import { BitcoinUnit } from "bitcoin-units"; import { BitcoinUnit } from "bitcoin-units";
import { type ClassValue, clsx } from "clsx"; import { type ClassValue, clsx } from "clsx";
import dayjs from "dayjs"; import dayjs from "dayjs";
@ -170,41 +168,6 @@ export function decodeZapInvoice(tags: string[][]) {
} }
} }
export async function checkForAppUpdates(silent: boolean) {
const update = await check();
if (!update) {
if (silent) return;
await message("You are on the latest version. Stay awesome!", {
title: "No Update Available",
kind: "info",
okLabel: "OK",
});
return;
}
if (update?.available) {
const yes = await ask(
`Update to ${update.version} is available!\n\nRelease notes: ${update.body}`,
{
title: "Update Available",
kind: "info",
okLabel: "Update",
cancelLabel: "Cancel",
},
);
if (yes) {
await update.downloadAndInstall();
await relaunch();
}
return;
}
}
export async function upload(filePath?: string) { export async function upload(filePath?: string) {
const allowExts = [ const allowExts = [
"png", "png",

View File

@ -1,14 +1,41 @@
import { commands } from '@/commands.gen' import { commands } from "@/commands.gen";
import { createFileRoute, redirect } from '@tanstack/react-router' import { createFileRoute, redirect } from "@tanstack/react-router";
import { ask } from "@tauri-apps/plugin-dialog";
import { relaunch } from "@tauri-apps/plugin-process";
import { check } from "@tauri-apps/plugin-updater";
export const Route = createFileRoute('/_app')({ async function checkForAppUpdates() {
beforeLoad: async () => { const update = await check();
const accounts = await commands.getAccounts()
if (!accounts.length) { if (update?.available) {
throw redirect({ to: '/new', replace: true }) const yes = await ask(
} `Update to ${update.version} is available!\n\nRelease notes: ${update.body}`,
{
title: "Update Available",
kind: "info",
okLabel: "Update",
cancelLabel: "Cancel",
},
);
return { accounts } if (yes) {
}, await update.downloadAndInstall();
}) await relaunch();
}
return;
}
}
export const Route = createFileRoute("/_app")({
beforeLoad: async () => {
await checkForAppUpdates();
const accounts = await commands.getAccounts();
if (!accounts.length) {
throw redirect({ to: "/new", replace: true });
}
return { accounts };
},
});

View File

@ -1,10 +1,7 @@
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
export default { export default {
content: [ content: ["./src/**/*.{js,ts,jsx,tsx}", "index.html"],
"./src/**/*.{js,ts,jsx,tsx}",
"index.html",
],
theme: { theme: {
extend: { extend: {
keyframes: { keyframes: {

View File

@ -2,19 +2,12 @@
"compilerOptions": { "compilerOptions": {
"target": "ESNext", "target": "ESNext",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"lib": [ "lib": ["ESNext", "ES2020", "DOM", "DOM.Iterable"],
"ESNext",
"ES2020",
"DOM",
"DOM.Iterable"
],
"module": "ESNext", "module": "ESNext",
"skipLibCheck": true, "skipLibCheck": true,
"baseUrl": "./", "baseUrl": "./",
"paths": { "paths": {
"@/*": [ "@/*": ["./src/*"]
"./src/*"
]
}, },
"moduleResolution": "bundler", "moduleResolution": "bundler",
"allowImportingTsExtensions": true, "allowImportingTsExtensions": true,
@ -26,11 +19,9 @@
"noUnusedLocals": true, "noUnusedLocals": true,
"noImplicitAny": false, "noImplicitAny": false,
"noUnusedParameters": true, "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true
}, },
"include": [ "include": ["src"],
"src"
],
"references": [ "references": [
{ {
"path": "./tsconfig.node.json" "path": "./tsconfig.node.json"

View File

@ -6,7 +6,5 @@
"moduleResolution": "bundler", "moduleResolution": "bundler",
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true
}, },
"include": [ "include": ["vite.config.ts"]
"vite.config.ts"
]
} }