Skip to content

πŸ†™ Upscayl - #1 Free and Open Source AI Image Upscaler for Linux, MacOS and Windows.

Update onboarding and fix autoupdate toggle

Nayam Amarshe80597ee5a31c
diff --git a/electron/index.ts b/electron/index.ts
index cf0f529..3f31acc 100644
--- a/electron/index.ts
+++ b/electron/index.ts
@@ -37,10 +37,6 @@ app.on("ready", async () => {
createMainWindow();
- if (!electronIsDev) {
- autoUpdater.checkForUpdates();
- }
-
log.info(
"πŸ†™ Upscayl version:",
app.getVersion(),
diff --git a/electron/main-window.ts b/electron/main-window.ts
index 0c824e7..56895b5 100644
--- a/electron/main-window.ts
+++ b/electron/main-window.ts
@@ -5,6 +5,7 @@ import { ELECTRON_COMMANDS } from "../common/electron-commands";
import { fetchLocalStorage } from "./utils/config-variables";
import electronIsDev from "electron-is-dev";
import { format } from "url";
+import { autoUpdater } from "electron-updater";
let mainWindow: BrowserWindow | undefined;
@@ -49,6 +50,19 @@ const createMainWindow = () => {
fetchLocalStorage();
+ if (!electronIsDev) {
+ console.log("πŸš€ Checking for updates");
+ mainWindow.webContents
+ .executeJavaScript('localStorage.getItem("autoUpdate");', true)
+ .then((lastSaved: string | null) => {
+ if (lastSaved !== null && lastSaved === "true") {
+ autoUpdater.checkForUpdates();
+ } else {
+ console.log("πŸš€ Auto Update is disabled");
+ }
+ });
+ }
+
mainWindow.webContents.send(ELECTRON_COMMANDS.OS, getPlatform());
mainWindow.setMenuBarVisibility(false);
diff --git a/package.json b/package.json
index d8dd08b..8718e6d 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "upscayl",
"private": true,
- "version": "2.15.0",
+ "version": "2.10.0",
"productName": "Upscayl",
"author": {
"name": "Nayam Amarshe",
diff --git a/renderer/atoms/user-settings-atom.ts b/renderer/atoms/user-settings-atom.ts
index 6ef89ed..b133732 100644
--- a/renderer/atoms/user-settings-atom.ts
+++ b/renderer/atoms/user-settings-atom.ts
@@ -76,3 +76,10 @@ export const tileSizeAtom = atomWithStorage<number | null>("tileSize", null);
// CLIENT SIDE ONLY
export const showSidebarAtom = atomWithStorage("showSidebar", true);
+
+export const autoUpdateAtom = atomWithStorage("autoUpdate", true);
+
+export const enableContributionAtom = atomWithStorage(
+ "enableContribution",
+ true,
+);
diff --git a/renderer/components/main-content/onboarding-dialog.tsx b/renderer/components/main-content/onboarding-dialog.tsx
index 0a43508..daae9a0 100644
--- a/renderer/components/main-content/onboarding-dialog.tsx
+++ b/renderer/components/main-content/onboarding-dialog.tsx
@@ -1,4 +1,4 @@
-import { useState } from "react";
+import { useEffect, useState } from "react";
import {
Dialog,
DialogContent,
@@ -7,15 +7,25 @@ import {
DialogHeader,
DialogTitle,
} from "../ui/dialog";
+import { cn } from "@/lib/utils";
+import SelectTheme from "@/components/sidebar/settings-tab/select-theme";
+import {
+ autoUpdateAtom,
+ enableContributionAtom,
+} from "@/atoms/user-settings-atom";
+import { useAtom } from "jotai";
type OnboardingStep = {
title: string;
description: string;
type: "info" | "settings";
- settings?: {
- type: "switch" | "input";
- label: string;
+ configurationOptions?: {
key: string;
+ type: "switch" | "input" | "video" | "component";
+ label?: string;
+ description?: string;
+ videoSrc?: string;
+ component?: any;
}[];
};
@@ -26,48 +36,75 @@ const onboardingSteps: OnboardingStep[] = [
type: "info",
},
{
- title: "Choose Your Preferences",
+ title: "Choose Your Preferences 🎨",
description: "Configure your initial settings.",
type: "settings",
- settings: [
+ configurationOptions: [
{
type: "switch",
label: "Enable automatic updates",
key: "autoUpdate",
},
{
- type: "input",
- label: "Default output folder",
- key: "outputFolder",
+ type: "switch",
+ label: "Help Improve Upscayl",
+ description: "Send anonymous usage data to help improve Upscayl.",
+ key: "improveUpscayl",
+ },
+ {
+ type: "component",
+ label: "Theme",
+ component: <SelectTheme hideLabel={true} />,
+ key: "theme",
+ },
+ ],
+ },
+ {
+ title: "How do I use Upscayl? πŸš€",
+ type: "info",
+ description: "Watch this short video to learn about the new features.",
+ configurationOptions: [
+ {
+ key: "video",
+ type: "video",
+ videoSrc: "https://www.youtube-nocookie.com/embed/3M77flVZlVY",
},
],
},
{
- title: "You're All Set!",
+ title: "You're All Set! πŸŽ‰",
description: "You can now start upscaling your images.",
type: "info",
},
];
-export function OnboardingDialog({
- open,
- onOpenChange,
-}: {
- open: boolean;
- onOpenChange: (open: boolean) => void;
-}) {
+export function OnboardingDialog() {
const [currentStep, setCurrentStep] = useState(0);
const [settings, setSettings] = useState<Record<string, any>>({});
+ const [open, setOpen] = useState(false);
+
const currentStepData = onboardingSteps[currentStep];
const isLastStep = currentStep === onboardingSteps.length - 1;
const isFirstStep = currentStep === 0;
+ const [autoUpdate, setAutoUpdate] = useAtom(autoUpdateAtom);
+ const [enableContribution, setEnableContribution] = useAtom(
+ enableContributionAtom,
+ );
+
+ useEffect(() => {
+ const storedValue = localStorage.getItem("showOnboarding");
+ if (storedValue !== null) {
+ setOpen(JSON.parse(storedValue));
+ } else {
+ setOpen(true);
+ }
+ }, []);
const handleNext = () => {
if (isLastStep) {
- onOpenChange(false);
- // Here you can handle saving the settings
- console.log("Final settings:", settings);
+ setOpen(false);
+ localStorage.setItem("showOnboarding", JSON.stringify(false));
} else {
setCurrentStep((prev) => prev + 1);
}
@@ -78,62 +115,98 @@ export function OnboardingDialog({
};
return (
- <Dialog open={open} onOpenChange={onOpenChange}>
+ <Dialog
+ open={open}
+ onOpenChange={(e) => {
+ setOpen(e);
+ }}
+ >
<DialogContent className="flex h-[80%] w-full max-w-[80%] flex-col items-center justify-center">
<DialogHeader>
<DialogTitle className="text-center text-4xl">
{currentStepData.title}
</DialogTitle>
- <DialogDescription className="text-center text-lg">
+ <DialogDescription className="text-center text-lg text-base-content/70">
{currentStepData.description}
</DialogDescription>
</DialogHeader>
- {currentStepData.type === "settings" && currentStepData.settings && (
- <div className="grid gap-4 py-4">
- {currentStepData.settings.map((setting) => (
+ {currentStepData.configurationOptions && (
+ <div
+ className={cn(
+ "flex h-full w-full flex-col rounded-sm bg-primary p-8 ",
+ currentStepData.type === "settings" && "h-auto w-auto gap-8",
+ )}
+ >
+ {currentStepData.configurationOptions.map((option) => (
<div
- key={setting.key}
- className="grid grid-cols-2 items-center gap-4"
+ key={option.key}
+ className="flex h-full w-full items-center justify-between gap-4"
>
- <label htmlFor={setting.key} className="text-right">
- {setting.label}
- </label>
- {setting.type === "switch" && (
+ {option.label && (
+ <label
+ htmlFor={option.key}
+ className="text-balance text-left text-sm uppercase text-primary-content"
+ >
+ {option.label}
+ </label>
+ )}
+ {option.type === "switch" && (
<input
type="checkbox"
className="toggle"
- defaultChecked
- id={setting.key}
- checked={settings[setting.key] || false}
- onChange={(e) =>
- handleSettingChange(setting.key, e.target.checked)
+ id={option.key}
+ checked={
+ option.key === "autoUpdate"
+ ? autoUpdate
+ : option.key === "improveUpscayl"
+ ? enableContribution
+ : false
}
+ onChange={(e) => {
+ if (option.key === "autoUpdate") {
+ setAutoUpdate(e.target.checked);
+ } else if (option.key === "improveUpscayl") {
+ setEnableContribution(e.target.checked);
+ }
+ }}
/>
)}
- {setting.type === "input" && (
+ {option.type === "input" && (
<input
className="input input-bordered"
- id={setting.key}
- value={settings[setting.key] || ""}
+ id={option.key}
+ value={settings[option.key] || ""}
onChange={(e) =>
- handleSettingChange(setting.key, e.target.value)
+ handleSettingChange(option.key, e.target.value)
}
/>
)}
+ {option.type === "video" && (
+ <iframe
+ className="h-full w-full"
+ src={option.videoSrc}
+ title="YouTube video player"
+ frameBorder="0"
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
+ referrerPolicy="strict-origin-when-cross-origin"
+ allowFullScreen
+ />
+ )}
+ {option.type === "component" && option.component}
</div>
))}
</div>
)}
- <DialogFooter>
- <button onClick={handleNext} className="btn btn-secondary">
+ <DialogFooter className="gap-2 md:gap-0">
+ <button onClick={handleNext} className="btn btn-secondary w-40">
{isLastStep ? "Get Started" : "Next"}
</button>
{!isFirstStep && (
<button
onClick={() => setCurrentStep((prev) => prev - 1)}
- className="btn btn-primary"
+ className="btn btn-primary w-40"
>
Back
</button>
diff --git a/renderer/components/sidebar/settings-tab/index.tsx b/renderer/components/sidebar/settings-tab/index.tsx
index 7574e46..788cbbc 100644
--- a/renderer/components/sidebar/settings-tab/index.tsx
+++ b/renderer/components/sidebar/settings-tab/index.tsx
@@ -1,4 +1,4 @@
-import { SelectTheme } from "./select-theme";
+import SelectTheme from "./select-theme";
import { SaveOutputFolderToggle } from "./save-output-folder-toggle";
import { InputGpuId } from "./input-gpu-id";
import { CustomModelsFolderSelect } from "./select-custom-models-folder";
@@ -60,10 +60,6 @@ function SettingsTab({
const [timeoutId, setTimeoutId] = useState(null);
const t = useAtomValue(translationAtom);
- useEffect(() => {
- themeChange(false);
- }, []);
-
// HANDLERS
const setExportType = (format: ImageFormat) => {
setSaveImageAs(format);
diff --git a/renderer/components/sidebar/settings-tab/select-image-scale.tsx b/renderer/components/sidebar/settings-tab/select-image-scale.tsx
index fb673f7..7663f3c 100644
--- a/renderer/components/sidebar/settings-tab/select-image-scale.tsx
+++ b/renderer/components/sidebar/settings-tab/select-image-scale.tsx
@@ -18,7 +18,7 @@ export function SelectImageScale({
return (
<div className={`${useCustomWidth && "opacity-50"}`}>
- <div className="flex flex-row gap-1">
+ <div className="flex flex-row items-center gap-2">
{hideInfo ? (
<>
<p className="text-sm">
@@ -26,13 +26,22 @@ export function SelectImageScale({
<span className="text-xs">({scale}X)</span>
</p>
{hideInfo && parseInt(scale) >= 6 && (
- <p
- className="badge badge-warning text-xs font-bold"
+ <span
+ className="text-xs font-bold text-error"
data-tooltip-id="tooltip"
data-tooltip-content={t("SETTINGS.IMAGE_SCALE.WARNING")}
>
- !
- </p>
+ <svg
+ className="h-4 w-4"
+ stroke="currentColor"
+ fill="currentColor"
+ stroke-width="0"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path d="M9.836 3.244c.963-1.665 3.365-1.665 4.328 0l8.967 15.504c.963 1.667-.24 3.752-2.165 3.752H3.034c-1.926 0-3.128-2.085-2.165-3.752ZM12 8.5a.75.75 0 0 0-.75.75v4.5a.75.75 0 0 0 1.5 0v-4.5A.75.75 0 0 0 12 8.5Zm1 9a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z"></path>
+ </svg>
+ </span>
)}
</>
) : (
diff --git a/renderer/components/sidebar/settings-tab/select-theme.tsx b/renderer/components/sidebar/settings-tab/select-theme.tsx
index 033b36c..6e50d3a 100644
--- a/renderer/components/sidebar/settings-tab/select-theme.tsx
+++ b/renderer/components/sidebar/settings-tab/select-theme.tsx
@@ -1,8 +1,9 @@
import { translationAtom } from "@/atoms/translations-atom";
import { useAtomValue } from "jotai";
-import React from "react";
+import React, { useEffect } from "react";
+import { themeChange } from "theme-change";
-export function SelectTheme() {
+const SelectTheme = ({ hideLabel }: { hideLabel?: boolean }) => {
const availableThemes = [
{ label: "upscayl", value: "upscayl" },
{ label: "light", value: "light" },
@@ -37,9 +38,15 @@ export function SelectTheme() {
];
const t = useAtomValue(translationAtom);
+ useEffect(() => {
+ themeChange(false);
+ }, []);
+
return (
- <div className="flex flex-col gap-2">
- <p className="text-sm font-medium">{t("SETTINGS.THEME.TITLE")}</p>
+ <div className="flex w-full flex-col gap-2">
+ {!hideLabel && (
+ <p className="text-sm font-medium">{t("SETTINGS.THEME.TITLE")}</p>
+ )}
<select data-choose-theme className="select select-primary">
{availableThemes.map((theme) => {
return (
@@ -51,4 +58,6 @@ export function SelectTheme() {
</select>
</div>
);
-}
+};
+
+export default SelectTheme;
diff --git a/renderer/components/sidebar/upscayl-tab/select-model-dialog.tsx b/renderer/components/sidebar/upscayl-tab/select-model-dialog.tsx
index 176c3b9..a146e2b 100644
--- a/renderer/components/sidebar/upscayl-tab/select-model-dialog.tsx
+++ b/renderer/components/sidebar/upscayl-tab/select-model-dialog.tsx
@@ -56,14 +56,14 @@ const SelectModelDialog = () => {
return (
<button
key={modelId}
- className="btn !h-auto !w-full !flex-col !items-start !p-4"
+ className="btn !h-auto !w-full !flex-col !items-start !rounded-sm !p-4"
onClick={() => handleModelSelect(modelId)}
>
<div className="font-semibold">{model.name}</div>
- <div className="mb-2 text-left font-normal leading-normal text-primary-foreground/50">
+ <div className="mb-2 text-left font-normal leading-normal text-opacity-50">
{model.description}
</div>
- <div className="relative h-52 w-full overflow-hidden rounded-md">
+ <div className="relative h-52 w-full overflow-hidden rounded-sm">
<div className="flex h-full w-full">
<img
src={`/model-comparison/${model.id}/before.webp`}
diff --git a/renderer/pages/index.tsx b/renderer/pages/index.tsx
index b0cecdc..77217ce 100644
--- a/renderer/pages/index.tsx
+++ b/renderer/pages/index.tsx
@@ -311,7 +311,7 @@ const Home = () => {
doubleUpscaylCounter={doubleUpscaylCounter}
setDimensions={setDimensions}
/>
- <OnboardingDialog open={false} onOpenChange={() => {}} />
+ <OnboardingDialog />
</div>
);
};
diff --git a/renderer/public/alert-icon.svg b/renderer/public/alert-icon.svg
new file mode 100644
index 0000000..d47cbbd
--- /dev/null
+++ b/renderer/public/alert-icon.svg
@@ -0,0 +1 @@
+<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" height="200px" width="200px" xmlns="http://www.w3.org/2000/svg"><path d="M9.836 3.244c.963-1.665 3.365-1.665 4.328 0l8.967 15.504c.963 1.667-.24 3.752-2.165 3.752H3.034c-1.926 0-3.128-2.085-2.165-3.752ZM12 8.5a.75.75 0 0 0-.75.75v4.5a.75.75 0 0 0 1.5 0v-4.5A.75.75 0 0 0 12 8.5Zm1 9a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z"></path></svg>
\ No newline at end of file