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;
|
||||
}[] = [];
|
||||
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");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
);
|
||||
|
@ -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"
|
||||
|
@ -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 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} />
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user