diff --git a/renderer/atoms/newsAtom.ts b/renderer/atoms/newsAtom.ts index ae36001..2122423 100644 --- a/renderer/atoms/newsAtom.ts +++ b/renderer/atoms/newsAtom.ts @@ -1,6 +1,4 @@ import { atomWithStorage } from "jotai/utils"; -export const newsAtom = atomWithStorage("news", { - seen: false, - version: null, -}); +export const newsSeenAtom = atomWithStorage("newsSeen", false); +export const newsAtom = atomWithStorage("news", []); diff --git a/renderer/components/NewsModal.tsx b/renderer/components/NewsModal.tsx index 10a1943..5a8f560 100644 --- a/renderer/components/NewsModal.tsx +++ b/renderer/components/NewsModal.tsx @@ -1,9 +1,12 @@ import React from "react"; -export const NewsModal = ({ show, setShow }) => { +export const NewsModal = ({ show, setShow, news }) => { + console.log("🚀 => file: NewsModal.tsx:4 => news:", news); + return (
+ + +
+

{news.title}

+
diff --git a/renderer/pages/index.tsx b/renderer/pages/index.tsx index 39a4842..60d5094 100644 --- a/renderer/pages/index.tsx +++ b/renderer/pages/index.tsx @@ -30,7 +30,8 @@ import { DoubleUpscaylPayload, ImageUpscaylPayload, } from "@common/types/types"; -import { newsAtom } from "@/atoms/newsAtom"; +import { NewsModal } from "@/components/NewsModal"; +import { newsAtom, newsSeenAtom } from "@/atoms/newsAtom"; const Home = () => { const allowedFileTypes = ["png", "jpg", "jpeg", "webp"]; @@ -57,6 +58,7 @@ const Home = () => { const [selectedTab, setSelectedTab] = useState(0); const [isLoading, setIsLoading] = useState(true); const [showCloudModal, setShowCloudModal] = useState(false); + const [showNewsModal, setShowNewsModal] = useState(false); // ATOMIC STATES const [outputPath, setOutputPath] = useAtom(outputPathAtom); @@ -70,6 +72,7 @@ const Home = () => { dontShowCloudModalAtom ); const noImageProcessing = useAtomValue(noImageProcessingAtom); + const [newsSeen, setNewsSeen] = useAtom(newsSeenAtom); const [news, setNews] = useAtom(newsAtom); const { logit } = useLog(); @@ -82,12 +85,9 @@ const Home = () => { /Upscayl\/([\d\.]+\d+)/ )[1]; setVersion(upscaylVersion); - // NEWS - if (news.seen === false) { - } }, []); - // EVENT LISTENERS + // ELECTRON EVENT LISTENERS useEffect(() => { const handleErrors = (data: string) => { if (data.includes("invalid gpu")) { @@ -221,19 +221,19 @@ const Home = () => { useEffect(() => { fetch("/news.json") .then((res) => { - console.log("🚀 => file: index.tsx:237 => res:", res); return res.blob(); }) .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()); - if (newsData[version]) { - console.log( - "🚀 => file: index.tsx:244 => newsData[version]:", - newsData[version] - ); - setNews(newsData[version]); + if (newsSeen === true) { + setShowNewsModal(false); + return; } + setNews(newsData); + setShowNewsModal(true); }); }, []); @@ -270,17 +270,13 @@ const Home = () => { // * HANDLERS const resetImagePaths = () => { logit("🔄 Resetting image paths"); - setDimensions({ width: null, height: null, }); - setProgress(""); - setImagePath(""); setUpscaledImagePath(""); - setBatchFolderPath(""); setUpscaledBatchFolderPath(""); }; @@ -525,6 +521,15 @@ const Home = () => { )} + { + setShowNewsModal(val); + setNews((prev) => ({ ...prev, seen: true })); + }} + news={news} + /> + {selectedTab === 0 && ( diff --git a/renderer/public/news.json b/renderer/public/news.json index a95866c..0967ef4 100644 --- a/renderer/public/news.json +++ b/renderer/public/news.json @@ -1,5 +1 @@ -{ - "2.9.3": { - "version": "2.9.3" - } -} +{}