Skip to content

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

Add turn off notifications feature

Nayam Amarshe3a459b835c05
diff --git a/electron/utils/config-variables.ts b/electron/utils/config-variables.ts
index 5ccd65c..a36fb47 100644
--- a/electron/utils/config-variables.ts
+++ b/electron/utils/config-variables.ts
@@ -14,6 +14,7 @@ export let childProcesses: {
kill: () => boolean;
}[] = [];
export let noImageProcessing: boolean = false;
+export let turnOffNotifications: boolean = false;
export function setImagePath(value: string | undefined): void {
imagePath = value;
@@ -70,6 +71,11 @@ export function setNoImageProcessing(value: boolean): void {
logit("πŸ–ΌοΈ Updating No Image Processing: ", noImageProcessing);
}
+export function setTurnOffNotifications(value: boolean): void {
+ turnOffNotifications = value;
+ logit("πŸ”• Updating Turn Off Notifications: ", turnOffNotifications);
+}
+
// LOCAL STORAGE
export function fetchLocalStorage(): void {
const mainWindow = getMainWindow();
@@ -134,4 +140,13 @@ export function fetchLocalStorage(): void {
setNoImageProcessing(lastSaved === "true");
}
});
+
+ // GET TURN OFF NOTIFICATIONS (BOOLEAN) FROM LOCAL STORAGE
+ mainWindow.webContents
+ .executeJavaScript('localStorage.getItem("turnOffNotifications");', true)
+ .then((lastSaved: string | null) => {
+ if (lastSaved !== null) {
+ setTurnOffNotifications(lastSaved === "true");
+ }
+ });
}
diff --git a/electron/utils/show-notification.ts b/electron/utils/show-notification.ts
index cb35ef9..00e80b8 100644
--- a/electron/utils/show-notification.ts
+++ b/electron/utils/show-notification.ts
@@ -1,6 +1,9 @@
import { Notification } from "electron/main";
+import { fetchLocalStorage, turnOffNotifications } from "./config-variables";
export default function showNotification(title: string, body: string) {
+ fetchLocalStorage();
+ if (turnOffNotifications) return;
new Notification({
title,
body,
diff --git a/renderer/atoms/userSettingsAtom.ts b/renderer/atoms/userSettingsAtom.ts
index c695a98..3679366 100644
--- a/renderer/atoms/userSettingsAtom.ts
+++ b/renderer/atoms/userSettingsAtom.ts
@@ -28,3 +28,8 @@ export const noImageProcessingAtom = atomWithStorage<boolean>(
export const compressionAtom = atomWithStorage<number>("compression", 0);
export const overwriteAtom = atomWithStorage("overwrite", false);
+
+export const turnOffNotificationsAtom = atomWithStorage(
+ "turnOffNotifications",
+ false
+);
diff --git a/renderer/components/settings-tab/CustomModelsFolderSelect.tsx b/renderer/components/settings-tab/CustomModelsFolderSelect.tsx
index 6d29f72..8f814bb 100644
--- a/renderer/components/settings-tab/CustomModelsFolderSelect.tsx
+++ b/renderer/components/settings-tab/CustomModelsFolderSelect.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import commands from "../../../electron/constants/commands";
+import commands from "../../../common/commands";
type CustomModelsFolderSelectProps = {
customModelsPath: string;
@@ -13,6 +13,15 @@ export function CustomModelsFolderSelect({
return (
<div className="flex flex-col items-start gap-2">
<p className="text-sm font-medium">ADD CUSTOM MODELS</p>
+ <p className="text-xs text-base-content/80">
+ You can add your own models easily. For more details:{" "}
+ <a
+ href="https://github.com/upscayl/custom-models/blob/main/README.md"
+ className="underline link"
+ target="_blank">
+ Custom Models Repository
+ </a>
+ </p>
<p className="text-sm text-base-content/60">{customModelsPath}</p>
<button
className="btn-primary btn"
diff --git a/renderer/components/settings-tab/TurnOffNotificationsToggle.tsx b/renderer/components/settings-tab/TurnOffNotificationsToggle.tsx
new file mode 100644
index 0000000..1c7bd4c
--- /dev/null
+++ b/renderer/components/settings-tab/TurnOffNotificationsToggle.tsx
@@ -0,0 +1,28 @@
+import { turnOffNotificationsAtom } from "@/atoms/userSettingsAtom";
+import { useAtom } from "jotai";
+
+const TurnOffNotificationsToggle = () => {
+ const [turnOffNotifications, setTurnOffNotifications] = useAtom(
+ turnOffNotificationsAtom
+ );
+
+ return (
+ <div className="flex flex-col gap-2">
+ <p className="text-sm font-medium">TURN OFF NOTIFICATIONS</p>
+ <p className="text-xs text-base-content/80">
+ If enabled, Upscayl will not send any system notifications on success or
+ failure.
+ </p>
+ <input
+ type="checkbox"
+ className="toggle"
+ checked={turnOffNotifications}
+ onClick={() => {
+ setTurnOffNotifications(!turnOffNotifications);
+ }}
+ />
+ </div>
+ );
+};
+
+export default TurnOffNotificationsToggle;
diff --git a/renderer/components/settings-tab/index.tsx b/renderer/components/settings-tab/index.tsx
index 49d34d4..b85552a 100644
--- a/renderer/components/settings-tab/index.tsx
+++ b/renderer/components/settings-tab/index.tsx
@@ -23,6 +23,7 @@ import { UpscaylCloudModal } from "../UpscaylCloudModal";
import { ResetSettings } from "./ResetSettings";
import ProcessImageToggle from "./ProcessImageToggle";
import { featureFlags } from "@common/feature-flags";
+import TurnOffNotificationsToggle from "./TurnOffNotificationsToggle";
interface IProps {
batchMode: boolean;
@@ -225,6 +226,7 @@ function SettingsTab({
/>
<OverwriteToggle />
+ <TurnOffNotificationsToggle />
{/* GPU ID INPUT */}
<GpuIdInput gpuId={gpuId} handleGpuIdChange={handleGpuIdChange} />
diff --git a/renderer/pages/index.tsx b/renderer/pages/index.tsx
index 94769ff..f2dc22f 100644
--- a/renderer/pages/index.tsx
+++ b/renderer/pages/index.tsx
@@ -1,6 +1,6 @@
"use client";
import { useState, useEffect, useCallback } from "react";
-import COMMAND from "../../electron/constants/commands";
+import COMMAND from "../../common/commands";
import { ReactCompareSlider } from "react-compare-slider";
import Header from "../components/Header";
import Footer from "../components/Footer";
@@ -272,9 +272,6 @@ const Home = () => {
}
}, []);
- // IMAGE PATH VALIDATION
- useEffect(() => {}, [imagePath]);
-
// LOADING STATE
useEffect(() => {
setIsLoading(false);