mirror of
https://github.com/upscayl/upscayl.git
synced 2024-12-18 02:16:01 +01:00
Add turn off notifications feature
This commit is contained in:
parent
d6842930a6
commit
3a459b835c
@ -14,6 +14,7 @@ export let childProcesses: {
|
|||||||
kill: () => boolean;
|
kill: () => boolean;
|
||||||
}[] = [];
|
}[] = [];
|
||||||
export let noImageProcessing: boolean = false;
|
export let noImageProcessing: boolean = false;
|
||||||
|
export let turnOffNotifications: boolean = false;
|
||||||
|
|
||||||
export function setImagePath(value: string | undefined): void {
|
export function setImagePath(value: string | undefined): void {
|
||||||
imagePath = value;
|
imagePath = value;
|
||||||
@ -70,6 +71,11 @@ export function setNoImageProcessing(value: boolean): void {
|
|||||||
logit("🖼️ Updating No Image Processing: ", noImageProcessing);
|
logit("🖼️ Updating No Image Processing: ", noImageProcessing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setTurnOffNotifications(value: boolean): void {
|
||||||
|
turnOffNotifications = value;
|
||||||
|
logit("🔕 Updating Turn Off Notifications: ", turnOffNotifications);
|
||||||
|
}
|
||||||
|
|
||||||
// LOCAL STORAGE
|
// LOCAL STORAGE
|
||||||
export function fetchLocalStorage(): void {
|
export function fetchLocalStorage(): void {
|
||||||
const mainWindow = getMainWindow();
|
const mainWindow = getMainWindow();
|
||||||
@ -134,4 +140,13 @@ export function fetchLocalStorage(): void {
|
|||||||
setNoImageProcessing(lastSaved === "true");
|
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");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import { Notification } from "electron/main";
|
import { Notification } from "electron/main";
|
||||||
|
import { fetchLocalStorage, turnOffNotifications } from "./config-variables";
|
||||||
|
|
||||||
export default function showNotification(title: string, body: string) {
|
export default function showNotification(title: string, body: string) {
|
||||||
|
fetchLocalStorage();
|
||||||
|
if (turnOffNotifications) return;
|
||||||
new Notification({
|
new Notification({
|
||||||
title,
|
title,
|
||||||
body,
|
body,
|
||||||
|
@ -28,3 +28,8 @@ export const noImageProcessingAtom = atomWithStorage<boolean>(
|
|||||||
export const compressionAtom = atomWithStorage<number>("compression", 0);
|
export const compressionAtom = atomWithStorage<number>("compression", 0);
|
||||||
|
|
||||||
export const overwriteAtom = atomWithStorage("overwrite", false);
|
export const overwriteAtom = atomWithStorage("overwrite", false);
|
||||||
|
|
||||||
|
export const turnOffNotificationsAtom = atomWithStorage(
|
||||||
|
"turnOffNotifications",
|
||||||
|
false
|
||||||
|
);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import commands from "../../../electron/constants/commands";
|
import commands from "../../../common/commands";
|
||||||
|
|
||||||
type CustomModelsFolderSelectProps = {
|
type CustomModelsFolderSelectProps = {
|
||||||
customModelsPath: string;
|
customModelsPath: string;
|
||||||
@ -13,6 +13,15 @@ export function CustomModelsFolderSelect({
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-start gap-2">
|
<div className="flex flex-col items-start gap-2">
|
||||||
<p className="text-sm font-medium">ADD CUSTOM MODELS</p>
|
<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>
|
<p className="text-sm text-base-content/60">{customModelsPath}</p>
|
||||||
<button
|
<button
|
||||||
className="btn-primary btn"
|
className="btn-primary btn"
|
||||||
|
@ -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;
|
@ -23,6 +23,7 @@ import { UpscaylCloudModal } from "../UpscaylCloudModal";
|
|||||||
import { ResetSettings } from "./ResetSettings";
|
import { ResetSettings } from "./ResetSettings";
|
||||||
import ProcessImageToggle from "./ProcessImageToggle";
|
import ProcessImageToggle from "./ProcessImageToggle";
|
||||||
import { featureFlags } from "@common/feature-flags";
|
import { featureFlags } from "@common/feature-flags";
|
||||||
|
import TurnOffNotificationsToggle from "./TurnOffNotificationsToggle";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
batchMode: boolean;
|
batchMode: boolean;
|
||||||
@ -225,6 +226,7 @@ function SettingsTab({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<OverwriteToggle />
|
<OverwriteToggle />
|
||||||
|
<TurnOffNotificationsToggle />
|
||||||
|
|
||||||
{/* GPU ID INPUT */}
|
{/* GPU ID INPUT */}
|
||||||
<GpuIdInput gpuId={gpuId} handleGpuIdChange={handleGpuIdChange} />
|
<GpuIdInput gpuId={gpuId} handleGpuIdChange={handleGpuIdChange} />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { useState, useEffect, useCallback } from "react";
|
import { useState, useEffect, useCallback } from "react";
|
||||||
import COMMAND from "../../electron/constants/commands";
|
import COMMAND from "../../common/commands";
|
||||||
import { ReactCompareSlider } from "react-compare-slider";
|
import { ReactCompareSlider } from "react-compare-slider";
|
||||||
import Header from "../components/Header";
|
import Header from "../components/Header";
|
||||||
import Footer from "../components/Footer";
|
import Footer from "../components/Footer";
|
||||||
@ -272,9 +272,6 @@ const Home = () => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// IMAGE PATH VALIDATION
|
|
||||||
useEffect(() => {}, [imagePath]);
|
|
||||||
|
|
||||||
// LOADING STATE
|
// LOADING STATE
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user