mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-28 01:10:52 +01:00
Fixed image path reset bug
This commit is contained in:
parent
a1dfbb2a0d
commit
290d718d33
@ -18,6 +18,11 @@ const Home = () => {
|
|||||||
const [loaded, setLoaded] = useState(false);
|
const [loaded, setLoaded] = useState(false);
|
||||||
const [version, setVersion] = useState("");
|
const [version, setVersion] = useState("");
|
||||||
|
|
||||||
|
const resetImagePaths = () => {
|
||||||
|
SetImagePath("");
|
||||||
|
setUpscaledImagePath("");
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setVersion(navigator.userAgent.match(/Upscayl\/([\d\.]+\d+)/)[1]);
|
setVersion(navigator.userAgent.match(/Upscayl\/([\d\.]+\d+)/)[1]);
|
||||||
}, []);
|
}, []);
|
||||||
@ -30,14 +35,12 @@ const Home = () => {
|
|||||||
alert(
|
alert(
|
||||||
"Error. Please make sure you have a Vulkan compatible GPU (Most modern GPUs support Vulkan). Upscayl does not work with CPU or iGPU sadly."
|
"Error. Please make sure you have a Vulkan compatible GPU (Most modern GPUs support Vulkan). Upscayl does not work with CPU or iGPU sadly."
|
||||||
);
|
);
|
||||||
SetImagePath("");
|
resetImagePaths();
|
||||||
upscaledImagePath("");
|
|
||||||
} else if (data.includes("failed")) {
|
} else if (data.includes("failed")) {
|
||||||
alert(
|
alert(
|
||||||
"This image is possibly corrupt or not supported by Upscayl. You could try converting the image into another format and upscaling again. Otherwise, make sure that the output path is correct and you have the proper write permissions for the directory. If not, then unfortuantely this image is not supported by Upscayl, sorry."
|
"This image is possibly corrupt or not supported by Upscayl. You could try converting the image into another format and upscaling again. Otherwise, make sure that the output path is correct and you have the proper write permissions for the directory. If not, then unfortuantely this image is not supported by Upscayl, sorry."
|
||||||
);
|
);
|
||||||
SetImagePath("");
|
resetImagePaths();
|
||||||
upscaledImagePath("");
|
|
||||||
} else if (data.length > 0 && data.length < 10) setProgress(data);
|
} else if (data.length > 0 && data.length < 10) setProgress(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -47,9 +50,7 @@ const Home = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const selectImageHandler = async () => {
|
const selectImageHandler = async () => {
|
||||||
SetImagePath("");
|
resetImagePaths();
|
||||||
setUpscaledImagePath("");
|
|
||||||
setProgress("");
|
|
||||||
var path = await window.electron.invoke(commands.SELECT_FILE);
|
var path = await window.electron.invoke(commands.SELECT_FILE);
|
||||||
|
|
||||||
if (path !== "cancelled") {
|
if (path !== "cancelled") {
|
||||||
@ -80,6 +81,8 @@ const Home = () => {
|
|||||||
|
|
||||||
const handleDrop = (e) => {
|
const handleDrop = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
resetImagePaths();
|
||||||
|
|
||||||
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);
|
||||||
@ -98,6 +101,7 @@ const Home = () => {
|
|||||||
|
|
||||||
const handlePaste = (e) => {
|
const handlePaste = (e) => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
resetImagePaths();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const type = e.clipboardData.items[0].type;
|
const type = e.clipboardData.items[0].type;
|
||||||
const filePath = e.clipboardData.files[0].path;
|
const filePath = e.clipboardData.files[0].path;
|
||||||
@ -126,7 +130,7 @@ const Home = () => {
|
|||||||
|
|
||||||
const upscaylHandler = async () => {
|
const upscaylHandler = async () => {
|
||||||
if (imagePath !== "") {
|
if (imagePath !== "") {
|
||||||
setUpscaledImagePath("");
|
resetImagePaths();
|
||||||
setProgress("Hold on...");
|
setProgress("Hold on...");
|
||||||
await window.electron.send(commands.UPSCAYL, {
|
await window.electron.send(commands.UPSCAYL, {
|
||||||
scaleFactor,
|
scaleFactor,
|
||||||
|
Loading…
Reference in New Issue
Block a user