1
0
mirror of https://github.com/upscayl/upscayl.git synced 2025-01-31 04:03:51 +01:00

Refined SettingsTab logging and changed emoji

This commit is contained in:
Feenix 2023-05-01 13:14:12 +05:30
parent f1505bdf00
commit 2f09776fb1
5 changed files with 67 additions and 112 deletions

View File

@ -213,7 +213,7 @@ ipcMain.handle(commands.SELECT_FILE, async () => {
return null; return null;
} }
logit(" Selected File Path: ", filePaths[0]); logit("📢 Selected File Path: ", filePaths[0]);
// CREATE input AND upscaled FOLDER // CREATE input AND upscaled FOLDER
return filePaths[0]; return filePaths[0];
} }
@ -231,7 +231,7 @@ ipcMain.handle(commands.SELECT_FOLDER, async (event, message) => {
return null; return null;
} else { } else {
folderPath = folderPaths[0]; folderPath = folderPaths[0];
logit(" Selected Folder Path: ", folderPath); logit("📢 Selected Folder Path: ", folderPath);
return folderPaths[0]; return folderPaths[0];
} }
}); });
@ -271,7 +271,7 @@ const getModels = (folderPath: string) => {
return null; return null;
} }
logit(" Detected Custom Models: ", models); logit("📢 Detected Custom Models: ", models);
return models; return models;
}; };
@ -279,7 +279,7 @@ ipcMain.on(commands.GET_MODELS_LIST, async (event, payload) => {
if (payload) { if (payload) {
customModelsFolderPath = payload; customModelsFolderPath = payload;
logit(" Custom Models Folder Path: ", customModelsFolderPath); logit("📢 Custom Models Folder Path: ", customModelsFolderPath);
mainWindow.webContents.send( mainWindow.webContents.send(
commands.CUSTOM_MODEL_FILES_LIST, commands.CUSTOM_MODEL_FILES_LIST,
@ -329,7 +329,7 @@ ipcMain.handle(commands.SELECT_CUSTOM_MODEL_FOLDER, async (event, message) => {
//------------------------Open Folder-----------------------------// //------------------------Open Folder-----------------------------//
ipcMain.on(commands.OPEN_FOLDER, async (event, payload) => { ipcMain.on(commands.OPEN_FOLDER, async (event, payload) => {
logit(" Opening Folder: ", payload); logit("📢 Opening Folder: ", payload);
shell.openPath(payload); shell.openPath(payload);
}); });
@ -338,7 +338,7 @@ ipcMain.on(commands.STOP, async (event, payload) => {
stopped = true; stopped = true;
childProcesses.forEach((child) => { childProcesses.forEach((child) => {
logit(" Stopping Upscaling Process", child.process.pid); logit("📢 Stopping Upscaling Process", child.process.pid);
child.kill(); child.kill();
}); });
}); });
@ -504,7 +504,7 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
// UPSCALE // UPSCALE
if (fs.existsSync(outFile)) { if (fs.existsSync(outFile)) {
// If already upscayled, just output that file // If already upscayled, just output that file
logit(" Already upscayled at: ", outFile); logit("📢 Already upscayled at: ", outFile);
mainWindow.webContents.send(commands.UPSCAYL_DONE, outFile); mainWindow.webContents.send(commands.UPSCAYL_DONE, outFile);
} else { } else {
const upscayl = spawnUpscayl( const upscayl = spawnUpscayl(
@ -538,7 +538,7 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
failed = true; failed = true;
} }
if (data.includes("has alpha channel")) { if (data.includes("has alpha channel")) {
logit(" INCLUDES ALPHA CHANNEL, CHANGING OUTFILE NAME!"); logit("📢 INCLUDES ALPHA CHANNEL, CHANGING OUTFILE NAME!");
isAlpha = true; isAlpha = true;
} }
}; };
@ -649,7 +649,7 @@ autoUpdater.on("update-available", ({ releaseNotes, releaseName }) => {
detail: detail:
"A new version is being downloaded. Please check GitHub for more details.", "A new version is being downloaded. Please check GitHub for more details.",
}; };
logit(" Update Available", releaseName, releaseNotes); logit("📢 Update Available", releaseName, releaseNotes);
dialog.showMessageBox(dialogOpts).then((returnValue) => {}); dialog.showMessageBox(dialogOpts).then((returnValue) => {});
}); });
@ -662,7 +662,7 @@ autoUpdater.on("update-downloaded", (event) => {
detail: detail:
"A new version has been downloaded. Restart the application to apply the updates.", "A new version has been downloaded. Restart the application to apply the updates.",
}; };
logit(" Update Downloaded"); logit("📢 Update Downloaded");
dialog.showMessageBox(dialogOpts).then((returnValue) => { dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) autoUpdater.quitAndInstall(); if (returnValue.response === 0) autoUpdater.quitAndInstall();
}); });

View File

@ -6,7 +6,7 @@ export const spawnUpscayl = (
command: string[], command: string[],
logit: (...args: any) => void logit: (...args: any) => void
) => { ) => {
logit(" Upscayl Command: ", command); logit("📢 Upscayl Command: ", command);
const spawnedProcess = spawn(execPath(binaryName), command, { const spawnedProcess = spawn(execPath(binaryName), command, {
cwd: undefined, cwd: undefined,

View File

@ -1,4 +1,4 @@
import { useAtom } from "jotai"; import { useAtom, useAtomValue } from "jotai";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import Select from "react-select"; import Select from "react-select";
import ReactTooltip from "react-tooltip"; import ReactTooltip from "react-tooltip";
@ -19,9 +19,6 @@ interface IProps {
outputPath: string; outputPath: string;
doubleUpscayl: boolean; doubleUpscayl: boolean;
setDoubleUpscayl: React.Dispatch<React.SetStateAction<boolean>>; setDoubleUpscayl: React.Dispatch<React.SetStateAction<boolean>>;
setModel: React.Dispatch<React.SetStateAction<string>>;
setSaveImageAs: React.Dispatch<React.SetStateAction<string>>;
setGpuId: React.Dispatch<React.SetStateAction<string>>;
dimensions: { dimensions: {
width: number | null; width: number | null;
height: number | null; height: number | null;
@ -41,9 +38,6 @@ function LeftPaneImageSteps({
outputPath, outputPath,
doubleUpscayl, doubleUpscayl,
setDoubleUpscayl, setDoubleUpscayl,
setModel,
setGpuId,
setSaveImageAs,
dimensions, dimensions,
}: IProps) { }: IProps) {
const [currentModel, setCurrentModel] = useState<{ const [currentModel, setCurrentModel] = useState<{
@ -54,52 +48,7 @@ function LeftPaneImageSteps({
value: null, value: null,
}); });
const [modelOptions] = useAtom(modelsListAtom); const modelOptions = useAtomValue(modelsListAtom);
const { logit } = useLog();
useEffect(() => {
themeChange(false);
if (!localStorage.getItem("saveImageAs")) {
logit(" Setting saveImageAs to png");
localStorage.setItem("saveImageAs", "png");
} else {
const currentlySavedImageFormat = localStorage.getItem("saveImageAs");
logit(
" Getting saveImageAs from localStorage",
currentlySavedImageFormat
);
setSaveImageAs(currentlySavedImageFormat);
}
if (!localStorage.getItem("model")) {
setCurrentModel(modelOptions[0]);
setModel(modelOptions[0].value);
localStorage.setItem("model", JSON.stringify(modelOptions[0]));
logit(" Setting model to", modelOptions[0].value);
} else {
const currentlySavedModel = JSON.parse(
localStorage.getItem("model")
) as (typeof modelOptions)[0];
setCurrentModel(currentlySavedModel);
setModel(currentlySavedModel.value);
logit(" Getting model from localStorage", currentlySavedModel.value);
}
if (!localStorage.getItem("gpuId")) {
localStorage.setItem("gpuId", "");
logit(" Setting gpuId to empty string");
} else {
const currentlySavedGpuId = localStorage.getItem("gpuId");
setGpuId(currentlySavedGpuId);
logit(" Getting gpuId from localStorage", currentlySavedGpuId);
}
}, []);
useEffect(() => {
logit(" Setting model to", currentModel.value);
}, [currentModel]);
return ( return (
<div className="animate-step-in animate flex h-screen flex-col gap-7 overflow-y-auto p-5 overflow-x-hidden"> <div className="animate-step-in animate flex h-screen flex-col gap-7 overflow-y-auto p-5 overflow-x-hidden">

View File

@ -1,9 +1,10 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { themeChange } from "theme-change"; import { themeChange } from "theme-change";
import commands from "../../electron/commands"; import commands from "../../electron/commands";
import { useAtom } from "jotai"; import { useAtom, useAtomValue } from "jotai";
import { customModelsPathAtom, scaleAtom } from "../atoms/userSettingsAtom"; import { customModelsPathAtom, scaleAtom } from "../atoms/userSettingsAtom";
import { modelsListAtom } from "../atoms/modelsListAtom"; import { modelsListAtom } from "../atoms/modelsListAtom";
import useLog from "./hooks/useLog";
interface IProps { interface IProps {
batchMode: boolean; batchMode: boolean;
@ -32,23 +33,27 @@ function SettingsTab({
label: null, label: null,
value: null, value: null,
}); });
const [rememberOutputFolder, setRememberOutputFolder] = useState(false);
const [isCopied, setIsCopied] = useState(false); const [isCopied, setIsCopied] = useState(false);
const [customModelsPath, setCustomModelsPath] = useAtom(customModelsPathAtom); const [customModelsPath, setCustomModelsPath] = useAtom(customModelsPathAtom);
const [modelOptions, setModelOptions] = useAtom(modelsListAtom); const modelOptions = useAtomValue(modelsListAtom);
const [scale, setScale] = useAtom(scaleAtom); const [scale, setScale] = useAtom(scaleAtom);
const [rememberOutputFolder, setRememberOutputFolder] = useState(false); const { logit } = useLog();
useEffect(() => { useEffect(() => {
themeChange(false); themeChange(false);
if (!localStorage.getItem("saveImageAs")) { if (!localStorage.getItem("saveImageAs")) {
logit("📢 Setting saveImageAs to png");
localStorage.setItem("saveImageAs", "png"); localStorage.setItem("saveImageAs", "png");
} else { } else {
const currentlySavedImageFormat = localStorage.getItem("saveImageAs"); const currentlySavedImageFormat = localStorage.getItem("saveImageAs");
logit(
"📢 Getting saveImageAs from localStorage",
currentlySavedImageFormat
);
setSaveImageAs(currentlySavedImageFormat); setSaveImageAs(currentlySavedImageFormat);
} }
@ -56,32 +61,36 @@ function SettingsTab({
setCurrentModel(modelOptions[0]); setCurrentModel(modelOptions[0]);
setModel(modelOptions[0].value); setModel(modelOptions[0].value);
localStorage.setItem("model", JSON.stringify(modelOptions[0])); localStorage.setItem("model", JSON.stringify(modelOptions[0]));
logit("📢 Setting model to", modelOptions[0].value);
} else { } else {
const currentlySavedModel = JSON.parse( const currentlySavedModel = JSON.parse(
localStorage.getItem("model") localStorage.getItem("model")
) as (typeof modelOptions)[0]; ) as (typeof modelOptions)[0];
setCurrentModel(currentlySavedModel); setCurrentModel(currentlySavedModel);
setModel(currentlySavedModel.value); setModel(currentlySavedModel.value);
logit("📢 Getting model from localStorage", currentlySavedModel.value);
} }
if (!localStorage.getItem("gpuId")) { if (!localStorage.getItem("gpuId")) {
localStorage.setItem("gpuId", ""); localStorage.setItem("gpuId", "");
logit("📢 Setting gpuId to empty string");
} else { } else {
const currentlySavedGpuId = localStorage.getItem("gpuId"); const currentlySavedGpuId = localStorage.getItem("gpuId");
setGpuId(currentlySavedGpuId); setGpuId(currentlySavedGpuId);
logit("📢 Getting gpuId from localStorage", currentlySavedGpuId);
} }
if (!localStorage.getItem("rememberOutputFolder")) { if (!localStorage.getItem("rememberOutputFolder")) {
logit("📢 Setting rememberOutputFolder to false");
localStorage.setItem("rememberOutputFolder", "false"); localStorage.setItem("rememberOutputFolder", "false");
} else { } else {
const currentlySavedRememberOutputFolder = localStorage.getItem( const currentlySavedRememberOutputFolder = localStorage.getItem(
"rememberOutputFolder" "rememberOutputFolder"
); );
console.log( logit(
"🚀 => file: SettingsTab.tsx:80 => currentlySavedRememberOutputFolder:", "📢 Getting rememberOutputFolder from localStorage",
currentlySavedRememberOutputFolder currentlySavedRememberOutputFolder
); );
setRememberOutputFolder( setRememberOutputFolder(
currentlySavedRememberOutputFolder === "true" ? true : false currentlySavedRememberOutputFolder === "true" ? true : false
); );
@ -89,7 +98,7 @@ function SettingsTab({
}, []); }, []);
useEffect(() => { useEffect(() => {
console.log("Current Model: ", currentModel); logit("📢 Setting model to", currentModel.value);
}, [currentModel]); }, [currentModel]);
// HANDLERS // HANDLERS

View File

@ -79,7 +79,7 @@ const Home = () => {
// LOG // LOG
window.electron.on(commands.LOG, (_, data: string) => { window.electron.on(commands.LOG, (_, data: string) => {
logit(` BACKEND REPORTED: `, data); logit(`📢 BACKEND REPORTED: `, data);
}); });
// UPSCAYL PROGRESS // UPSCAYL PROGRESS
@ -88,7 +88,7 @@ const Home = () => {
setProgress(data); setProgress(data);
} }
handleErrors(data); handleErrors(data);
logit(` UPSCAYL_PROGRESS: `, data); logit(`📢 UPSCAYL_PROGRESS: `, data);
}); });
// FOLDER UPSCAYL PROGRESS // FOLDER UPSCAYL PROGRESS
@ -97,7 +97,7 @@ const Home = () => {
setProgress(data); setProgress(data);
} }
handleErrors(data); handleErrors(data);
logit(` FOLDER_UPSCAYL_PROGRESS: `, data); logit(`📢 FOLDER_UPSCAYL_PROGRESS: `, data);
}); });
// DOUBLE UPSCAYL PROGRESS // DOUBLE UPSCAYL PROGRESS
@ -109,7 +109,7 @@ const Home = () => {
setProgress(data); setProgress(data);
} }
handleErrors(data); handleErrors(data);
logit(` DOUBLE_UPSCAYL_PROGRESS: `, data); logit(`📢 DOUBLE_UPSCAYL_PROGRESS: `, data);
}); });
// VIDEO UPSCAYL PROGRESS // VIDEO UPSCAYL PROGRESS
@ -118,7 +118,7 @@ const Home = () => {
setProgress(data); setProgress(data);
} }
handleErrors(data); handleErrors(data);
logit(` UPSCAYL_VIDEO_PROGRESS: `, data); logit(`📢 UPSCAYL_VIDEO_PROGRESS: `, data);
}); });
// UPSCAYL DONE // UPSCAYL DONE
@ -126,14 +126,14 @@ const Home = () => {
setProgress(""); setProgress("");
setUpscaledImagePath(data); setUpscaledImagePath(data);
logit("upscaledImagePath: ", upscaledImagePath); logit("upscaledImagePath: ", upscaledImagePath);
logit(` UPSCAYL_DONE: `, data); logit(`📢 UPSCAYL_DONE: `, data);
}); });
// FOLDER UPSCAYL DONE // FOLDER UPSCAYL DONE
window.electron.on(commands.FOLDER_UPSCAYL_DONE, (_, data: string) => { window.electron.on(commands.FOLDER_UPSCAYL_DONE, (_, data: string) => {
setProgress(""); setProgress("");
setUpscaledBatchFolderPath(data); setUpscaledBatchFolderPath(data);
logit(` FOLDER_UPSCAYL_DONE: `, data); logit(`📢 FOLDER_UPSCAYL_DONE: `, data);
}); });
// DOUBLE UPSCAYL DONE // DOUBLE UPSCAYL DONE
@ -141,21 +141,21 @@ const Home = () => {
setProgress(""); setProgress("");
setDoubleUpscaylCounter(0); setDoubleUpscaylCounter(0);
setUpscaledImagePath(data); setUpscaledImagePath(data);
logit(` DOUBLE_UPSCAYL_DONE: `, data); logit(`📢 DOUBLE_UPSCAYL_DONE: `, data);
}); });
// VIDEO UPSCAYL DONE // VIDEO UPSCAYL DONE
window.electron.on(commands.UPSCAYL_VIDEO_DONE, (_, data: string) => { window.electron.on(commands.UPSCAYL_VIDEO_DONE, (_, data: string) => {
setProgress(""); setProgress("");
setUpscaledVideoPath(data); setUpscaledVideoPath(data);
logit(` UPSCAYL_VIDEO_DONE: `, data); logit(`📢 UPSCAYL_VIDEO_DONE: `, data);
}); });
// CUSTOM FOLDER LISTENER // CUSTOM FOLDER LISTENER
window.electron.on( window.electron.on(
commands.CUSTOM_MODEL_FILES_LIST, commands.CUSTOM_MODEL_FILES_LIST,
(_, data: string[]) => { (_, data: string[]) => {
logit(` CUSTOM_MODEL_FILES_LIST: `, data); logit(`📢 CUSTOM_MODEL_FILES_LIST: `, data);
const newModelOptions = data.map((model) => { const newModelOptions = data.map((model) => {
return { return {
value: model, value: model,
@ -182,7 +182,7 @@ const Home = () => {
if (customModelsPath !== null) { if (customModelsPath !== null) {
window.electron.send(commands.GET_MODELS_LIST, customModelsPath); window.electron.send(commands.GET_MODELS_LIST, customModelsPath);
logit(" GET_MODELS_LIST: ", customModelsPath); logit("📢 GET_MODELS_LIST: ", customModelsPath);
} }
}, []); }, []);
@ -204,10 +204,10 @@ const Home = () => {
useEffect(() => { useEffect(() => {
if (imagePath.length > 0 && !isVideo) { if (imagePath.length > 0 && !isVideo) {
logit(" imagePath: ", imagePath); logit("📢 imagePath: ", imagePath);
const extension = imagePath.toLocaleLowerCase().split(".").pop(); const extension = imagePath.toLocaleLowerCase().split(".").pop();
logit(" Extension: ", extension); logit("📢 Extension: ", extension);
if (!allowedFileTypes.includes(extension.toLowerCase())) { if (!allowedFileTypes.includes(extension.toLowerCase())) {
alert("Please select an image"); alert("Please select an image");
@ -228,7 +228,7 @@ const Home = () => {
}, [imagePath, videoPath]); }, [imagePath, videoPath]);
const resetImagePaths = () => { const resetImagePaths = () => {
logit(" Resetting image paths"); logit("📢 Resetting image paths");
setDimensions({ setDimensions({
width: null, width: null,
@ -273,10 +273,10 @@ const Home = () => {
var path = await window.electron.invoke(commands.SELECT_FILE); var path = await window.electron.invoke(commands.SELECT_FILE);
if (path !== null) { if (path !== null) {
logit(" Selected Image Path: ", path); logit("📢 Selected Image Path: ", path);
SetImagePath(path); SetImagePath(path);
var dirname = path.match(/(.*)[\/\\]/)[1] || ""; var dirname = path.match(/(.*)[\/\\]/)[1] || "";
logit(" Selected Image Directory: ", dirname); logit("📢 Selected Image Directory: ", dirname);
setOutputPath(dirname); setOutputPath(dirname);
} }
}; };
@ -287,11 +287,11 @@ const Home = () => {
var path = await window.electron.invoke(commands.SELECT_FOLDER); var path = await window.electron.invoke(commands.SELECT_FOLDER);
if (path !== null) { if (path !== null) {
logit(" Selected Folder Path: ", path); logit("📢 Selected Folder Path: ", path);
setBatchFolderPath(path); setBatchFolderPath(path);
setOutputPath(path + "_upscayled"); setOutputPath(path + "_upscayled");
} else { } else {
logit(" Folder selection cancelled"); logit("📢 Folder selection cancelled");
setBatchFolderPath(""); setBatchFolderPath("");
setOutputPath(""); setOutputPath("");
} }
@ -307,7 +307,7 @@ const Home = () => {
const handleModelChange = (e: any) => { const handleModelChange = (e: any) => {
setModel(e.value); setModel(e.value);
logit(" Model changed: ", e.value); logit("📢 Model changed: ", e.value);
localStorage.setItem( localStorage.setItem(
"model", "model",
JSON.stringify({ label: e.label, value: e.value }) JSON.stringify({ label: e.label, value: e.value })
@ -329,7 +329,7 @@ const Home = () => {
}; };
const openFolderHandler = (e) => { const openFolderHandler = (e) => {
logit(" OPEN_FOLDER: ", upscaledBatchFolderPath); logit("📢 OPEN_FOLDER: ", upscaledBatchFolderPath);
window.electron.send(commands.OPEN_FOLDER, upscaledBatchFolderPath); window.electron.send(commands.OPEN_FOLDER, upscaledBatchFolderPath);
}; };
@ -341,7 +341,7 @@ const Home = () => {
e.dataTransfer.items.length === 0 || e.dataTransfer.items.length === 0 ||
e.dataTransfer.files.length === 0 e.dataTransfer.files.length === 0
) { ) {
logit(" No valid files dropped"); logit("📢 No valid files dropped");
alert("Please drag and drop an image"); alert("Please drag and drop an image");
return; return;
} }
@ -349,25 +349,25 @@ const Home = () => {
const type = e.dataTransfer.items[0].type; const type = e.dataTransfer.items[0].type;
const filePath = e.dataTransfer.files[0].path; const filePath = e.dataTransfer.files[0].path;
const extension = e.dataTransfer.files[0].name.split(".").at(-1); const extension = e.dataTransfer.files[0].name.split(".").at(-1);
logit(" Dropped file: ", JSON.stringify({ type, filePath, extension })); logit("📢 Dropped file: ", JSON.stringify({ type, filePath, extension }));
if ( if (
(!type.includes("image") && !type.includes("video")) || (!type.includes("image") && !type.includes("video")) ||
(!allowedFileTypes.includes(extension.toLowerCase()) && (!allowedFileTypes.includes(extension.toLowerCase()) &&
!allowedVideoFileTypes.includes(extension.toLowerCase())) !allowedVideoFileTypes.includes(extension.toLowerCase()))
) { ) {
logit(" Invalid file dropped"); logit("📢 Invalid file dropped");
alert("Please drag and drop an image"); alert("Please drag and drop an image");
} else { } else {
if (isVideo) { if (isVideo) {
setVideoPath(filePath); setVideoPath(filePath);
} else { } else {
logit(" Setting image path: ", filePath); logit("📢 Setting image path: ", filePath);
SetImagePath(filePath); SetImagePath(filePath);
} }
var dirname = filePath.match(/(.*)[\/\\]/)[1] || ""; var dirname = filePath.match(/(.*)[\/\\]/)[1] || "";
logit(" Setting output path: ", dirname); logit("📢 Setting output path: ", dirname);
setOutputPath(dirname); setOutputPath(dirname);
} }
}; };
@ -380,7 +380,7 @@ const Home = () => {
const filePath = e.clipboardData.files[0].path; const filePath = e.clipboardData.files[0].path;
const extension = e.clipboardData.files[0].name.split(".").at(-1); const extension = e.clipboardData.files[0].name.split(".").at(-1);
logit(" Pasted file: ", JSON.stringify({ type, filePath, extension })); logit("📢 Pasted file: ", JSON.stringify({ type, filePath, extension }));
if ( if (
!type.includes("image") && !type.includes("image") &&
@ -390,7 +390,7 @@ const Home = () => {
} else { } else {
SetImagePath(filePath); SetImagePath(filePath);
var dirname = filePath.match(/(.*)[\/\\]/)[1] || ""; var dirname = filePath.match(/(.*)[\/\\]/)[1] || "";
logit(" Setting output path: ", dirname); logit("📢 Setting output path: ", dirname);
setOutputPath(dirname); setOutputPath(dirname);
} }
}; };
@ -398,13 +398,13 @@ const Home = () => {
const outputHandler = async () => { const outputHandler = async () => {
var path = await window.electron.invoke(commands.SELECT_FOLDER); var path = await window.electron.invoke(commands.SELECT_FOLDER);
if (path !== null) { if (path !== null) {
logit(" Setting Output Path: ", path); logit("📢 Setting Output Path: ", path);
setOutputPath(path); setOutputPath(path);
const rememberOutputFolder = localStorage.getItem("rememberOutputFolder"); const rememberOutputFolder = localStorage.getItem("rememberOutputFolder");
if (rememberOutputFolder) { if (rememberOutputFolder) {
logit(" Remembering Output Folder: ", path); logit("📢 Remembering Output Folder: ", path);
localStorage.setItem("lastOutputFolderPath", path); localStorage.setItem("lastOutputFolderPath", path);
} }
} else { } else {
@ -416,7 +416,7 @@ const Home = () => {
if (isVideo) { if (isVideo) {
setUpscaledVideoPath(""); setUpscaledVideoPath("");
} else { } else {
logit(" Resetting Upscaled Image Path"); logit("📢 Resetting Upscaled Image Path");
setUpscaledImagePath(""); setUpscaledImagePath("");
} }
@ -432,7 +432,7 @@ const Home = () => {
saveImageAs, saveImageAs,
scale, scale,
}); });
logit(" DOUBLE_UPSCAYL"); logit("📢 DOUBLE_UPSCAYL");
} else if (batchMode) { } else if (batchMode) {
setDoubleUpscayl(false); setDoubleUpscayl(false);
window.electron.send(commands.FOLDER_UPSCAYL, { window.electron.send(commands.FOLDER_UPSCAYL, {
@ -444,7 +444,7 @@ const Home = () => {
saveImageAs, saveImageAs,
scale, scale,
}); });
logit(" FOLDER_UPSCAYL"); logit("📢 FOLDER_UPSCAYL");
} else { } else {
window.electron.send(commands.UPSCAYL, { window.electron.send(commands.UPSCAYL, {
scaleFactor, scaleFactor,
@ -455,7 +455,7 @@ const Home = () => {
saveImageAs, saveImageAs,
scale, scale,
}); });
logit(" UPSCAYL"); logit("📢 UPSCAYL");
} }
} }
// else if (isVideo && videoPath !== "") { // else if (isVideo && videoPath !== "") {
@ -470,19 +470,19 @@ const Home = () => {
// } // }
else { else {
alert(`Please select ${isVideo ? "a video" : "an image"} to upscale`); alert(`Please select ${isVideo ? "a video" : "an image"} to upscale`);
logit(" No valid image selected"); logit("📢 No valid image selected");
} }
}; };
const stopHandler = () => { const stopHandler = () => {
window.electron.send(commands.STOP); window.electron.send(commands.STOP);
logit(" Stopping Upscayl"); logit("📢 Stopping Upscayl");
resetImagePaths(); resetImagePaths();
}; };
const formatPath = (path) => { const formatPath = (path) => {
//USE REGEX TO GET THE FILENAME AND ENCODE IT INTO PROPER FORM IN ORDER TO AVOID ERRORS DUE TO SPECIAL CHARACTERS //USE REGEX TO GET THE FILENAME AND ENCODE IT INTO PROPER FORM IN ORDER TO AVOID ERRORS DUE TO SPECIAL CHARACTERS
logit(" Formatting path: ", path); logit("📢 Formatting path: ", path);
return path.replace( return path.replace(
/([^/\\]+)$/i, /([^/\\]+)$/i,
encodeURIComponent(path.match(/[^/\\]+$/i)[0]) encodeURIComponent(path.match(/[^/\\]+$/i)[0])
@ -553,9 +553,6 @@ const Home = () => {
outputPath={outputPath} outputPath={outputPath}
doubleUpscayl={doubleUpscayl} doubleUpscayl={doubleUpscayl}
setDoubleUpscayl={setDoubleUpscayl} setDoubleUpscayl={setDoubleUpscayl}
setModel={setModel}
setGpuId={setGpuId}
setSaveImageAs={setSaveImageAs}
dimensions={dimensions} dimensions={dimensions}
/> />
)} )}