mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-24 07:30:19 +01:00
Fix news modal
This commit is contained in:
parent
2c4e7b256b
commit
6f92b5dce1
@ -1,6 +1,4 @@
|
|||||||
import { atomWithStorage } from "jotai/utils";
|
import { atomWithStorage } from "jotai/utils";
|
||||||
|
|
||||||
export const newsAtom = atomWithStorage("news", {
|
export const newsSeenAtom = atomWithStorage("newsSeen", false);
|
||||||
seen: false,
|
export const newsAtom = atomWithStorage("news", []);
|
||||||
version: null,
|
|
||||||
});
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export const NewsModal = ({ show, setShow }) => {
|
export const NewsModal = ({ show, setShow, news }) => {
|
||||||
|
console.log("🚀 => file: NewsModal.tsx:4 => news:", news);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dialog className={`modal ${show && "modal-open"}`}>
|
<dialog className={`modal ${show && "modal-open"}`}>
|
||||||
<div className="modal-box flex flex-col text-center items-center gap-4">
|
<div className="modal-box flex flex-col text-center items-center gap-4">
|
||||||
|
<button onClick={() => setShow(false)}>Don't show again</button>
|
||||||
<button
|
<button
|
||||||
className="absolute top-2 right-4 btn btn-circle"
|
className="absolute top-2 right-4 btn btn-circle"
|
||||||
onClick={() => setShow(false)}>
|
onClick={() => setShow(false)}>
|
||||||
@ -29,6 +32,10 @@ export const NewsModal = ({ show, setShow }) => {
|
|||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<div className="h-80">
|
||||||
|
<h2 className="text-2xl font-bold text-center">{news.title}</h2>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="dialog" className="modal-backdrop">
|
<form method="dialog" className="modal-backdrop">
|
||||||
|
@ -30,7 +30,8 @@ import {
|
|||||||
DoubleUpscaylPayload,
|
DoubleUpscaylPayload,
|
||||||
ImageUpscaylPayload,
|
ImageUpscaylPayload,
|
||||||
} from "@common/types/types";
|
} from "@common/types/types";
|
||||||
import { newsAtom } from "@/atoms/newsAtom";
|
import { NewsModal } from "@/components/NewsModal";
|
||||||
|
import { newsAtom, newsSeenAtom } from "@/atoms/newsAtom";
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
const allowedFileTypes = ["png", "jpg", "jpeg", "webp"];
|
const allowedFileTypes = ["png", "jpg", "jpeg", "webp"];
|
||||||
@ -57,6 +58,7 @@ const Home = () => {
|
|||||||
const [selectedTab, setSelectedTab] = useState(0);
|
const [selectedTab, setSelectedTab] = useState(0);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [showCloudModal, setShowCloudModal] = useState(false);
|
const [showCloudModal, setShowCloudModal] = useState(false);
|
||||||
|
const [showNewsModal, setShowNewsModal] = useState(false);
|
||||||
|
|
||||||
// ATOMIC STATES
|
// ATOMIC STATES
|
||||||
const [outputPath, setOutputPath] = useAtom(outputPathAtom);
|
const [outputPath, setOutputPath] = useAtom(outputPathAtom);
|
||||||
@ -70,6 +72,7 @@ const Home = () => {
|
|||||||
dontShowCloudModalAtom
|
dontShowCloudModalAtom
|
||||||
);
|
);
|
||||||
const noImageProcessing = useAtomValue(noImageProcessingAtom);
|
const noImageProcessing = useAtomValue(noImageProcessingAtom);
|
||||||
|
const [newsSeen, setNewsSeen] = useAtom(newsSeenAtom);
|
||||||
const [news, setNews] = useAtom(newsAtom);
|
const [news, setNews] = useAtom(newsAtom);
|
||||||
|
|
||||||
const { logit } = useLog();
|
const { logit } = useLog();
|
||||||
@ -82,12 +85,9 @@ const Home = () => {
|
|||||||
/Upscayl\/([\d\.]+\d+)/
|
/Upscayl\/([\d\.]+\d+)/
|
||||||
)[1];
|
)[1];
|
||||||
setVersion(upscaylVersion);
|
setVersion(upscaylVersion);
|
||||||
// NEWS
|
|
||||||
if (news.seen === false) {
|
|
||||||
}
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// EVENT LISTENERS
|
// ELECTRON EVENT LISTENERS
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleErrors = (data: string) => {
|
const handleErrors = (data: string) => {
|
||||||
if (data.includes("invalid gpu")) {
|
if (data.includes("invalid gpu")) {
|
||||||
@ -221,19 +221,19 @@ const Home = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("/news.json")
|
fetch("/news.json")
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log("🚀 => file: index.tsx:237 => res:", res);
|
|
||||||
return res.blob();
|
return res.blob();
|
||||||
})
|
})
|
||||||
.then(async (data) => {
|
.then(async (data) => {
|
||||||
const version = navigator?.userAgent?.match(/Upscayl\/([\d\.]+\d+)/)[1];
|
const currentVersion = navigator?.userAgent?.match(
|
||||||
|
/Upscayl\/([\d\.]+\d+)/
|
||||||
|
)[1];
|
||||||
const newsData = JSON.parse(await data.text());
|
const newsData = JSON.parse(await data.text());
|
||||||
if (newsData[version]) {
|
if (newsSeen === true) {
|
||||||
console.log(
|
setShowNewsModal(false);
|
||||||
"🚀 => file: index.tsx:244 => newsData[version]:",
|
return;
|
||||||
newsData[version]
|
|
||||||
);
|
|
||||||
setNews(newsData[version]);
|
|
||||||
}
|
}
|
||||||
|
setNews(newsData);
|
||||||
|
setShowNewsModal(true);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -270,17 +270,13 @@ const Home = () => {
|
|||||||
// * HANDLERS
|
// * HANDLERS
|
||||||
const resetImagePaths = () => {
|
const resetImagePaths = () => {
|
||||||
logit("🔄 Resetting image paths");
|
logit("🔄 Resetting image paths");
|
||||||
|
|
||||||
setDimensions({
|
setDimensions({
|
||||||
width: null,
|
width: null,
|
||||||
height: null,
|
height: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
setProgress("");
|
setProgress("");
|
||||||
|
|
||||||
setImagePath("");
|
setImagePath("");
|
||||||
setUpscaledImagePath("");
|
setUpscaledImagePath("");
|
||||||
|
|
||||||
setBatchFolderPath("");
|
setBatchFolderPath("");
|
||||||
setUpscaledBatchFolderPath("");
|
setUpscaledBatchFolderPath("");
|
||||||
};
|
};
|
||||||
@ -525,6 +521,15 @@ const Home = () => {
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<NewsModal
|
||||||
|
show={showNewsModal}
|
||||||
|
setShow={(val: boolean) => {
|
||||||
|
setShowNewsModal(val);
|
||||||
|
setNews((prev) => ({ ...prev, seen: true }));
|
||||||
|
}}
|
||||||
|
news={news}
|
||||||
|
/>
|
||||||
|
|
||||||
<Tabs selectedTab={selectedTab} setSelectedTab={setSelectedTab} />
|
<Tabs selectedTab={selectedTab} setSelectedTab={setSelectedTab} />
|
||||||
|
|
||||||
{selectedTab === 0 && (
|
{selectedTab === 0 && (
|
||||||
|
@ -1,5 +1 @@
|
|||||||
{
|
{}
|
||||||
"2.9.3": {
|
|
||||||
"version": "2.9.3"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user