Buckets:
| import { createMemo } from "solid-js" | |
| import type { UpdaterState } from "@/updater" | |
| import { usePlatform } from "@/context/platform" | |
| import { useLanguage } from "@/context/language" | |
| import { showToast } from "@/utils/toast" | |
| export function updaterAction(state: UpdaterState | undefined) { | |
| if (!state) return { label: "settings.updates.action.checkNow" as const } | |
| switch (state.status) { | |
| case "checking": | |
| return { label: "settings.updates.action.checking" as const } | |
| case "downloading": | |
| return { label: "settings.updates.action.downloading" as const } | |
| case "ready": | |
| return { label: "toast.update.action.installRestart" as const, run: "install" as const } | |
| case "installing": | |
| return { label: "settings.updates.action.installing" as const } | |
| case "disabled": | |
| return { label: "settings.updates.action.checkNow" as const } | |
| default: | |
| return { label: "settings.updates.action.checkNow" as const, run: "check" as const } | |
| } | |
| } | |
| export function useUpdaterAction() { | |
| const platform = usePlatform() | |
| const language = useLanguage() | |
| const action = createMemo(() => updaterAction(platform.updater?.state())) | |
| return { | |
| action, | |
| async run() { | |
| const run = action().run | |
| if (run === "install") return platform.updater?.install() | |
| if (run !== "check") return | |
| const state = await platform.updater?.check() | |
| if (state?.status === "up-to-date") { | |
| showToast({ | |
| variant: "success", | |
| icon: "circle-check", | |
| title: language.t("settings.updates.toast.latest.title"), | |
| description: language.t("settings.updates.toast.latest.description", { version: platform.version ?? "" }), | |
| }) | |
| } | |
| if (state?.status === "error") { | |
| showToast({ title: language.t("common.requestFailed"), description: state.message }) | |
| } | |
| }, | |
| } | |
| } | |
Xet Storage Details
- Size:
- 1.87 kB
- Xet hash:
- 4f3389932bc6db86e70aa7bab8a9f5f903c00c2af321bcab201e947c95e647d3
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.