From 09b26542752b4c6b13e91ceae3255b67bd98f82c Mon Sep 17 00:00:00 2001
From: Victor Borges <victor1882@outlook.com>
Date: Wed, 30 Apr 2025 00:10:42 -0300
Subject: add pagination support

---
 src/index.tsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'src/index.tsx')

diff --git a/src/index.tsx b/src/index.tsx
index 28ae219..a381e1c 100755
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -182,7 +182,7 @@ function Content() {
 }
 
 export default definePlugin(() => {
-  const patch = patchPartnerEventStore();
+  const patches = patchPartnerEventStore();
 
   return {
     name: "Bazzite Changelog Viewer",
@@ -190,7 +190,9 @@ export default definePlugin(() => {
     icon: <FaClipboardList />,
     content: <Content />,
     onDismount() {
-      patch.unpatch();
+      patches.forEach(patch => {
+        patch.unpatch();
+      });
     },
   };
 });
-- 
cgit v1.2.3


From 929466b648cd4cbcdc671ccb2efa8e944a86a74b Mon Sep 17 00:00:00 2001
From: Victor Borges <victor1882@outlook.com>
Date: Wed, 30 Apr 2025 00:12:09 -0300
Subject: reformat code

---
 src/index.tsx | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

(limited to 'src/index.tsx')

diff --git a/src/index.tsx b/src/index.tsx
index a381e1c..74af918 100755
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,11 +1,11 @@
-import { useEffect, useState } from "react";
-import { FaClipboardList } from "react-icons/fa";
-import { definePlugin } from "decky-frontend-lib";
+import {useEffect, useState} from "react";
+import {FaClipboardList} from "react-icons/fa";
+import {definePlugin} from "decky-frontend-lib";
 import remarkHtml from "remark-html"
 import remarkParse from "remark-parse"
 import remarkGfm from "remark-gfm"
-import { unified } from "unified"
-import { patchPartnerEventStore } from "./PartnerEventStorePatch";
+import {unified} from "unified"
+import {patchPartnerEventStore} from "./PartnerEventStorePatch";
 import {staticClasses} from "@decky/ui";
 
 function Content() {
@@ -29,10 +29,10 @@ function Content() {
 
       const data = await response.json();
       const html = await unified()
-            .use(remarkParse)
-            .use(remarkGfm)
-            .use(remarkHtml)
-            .process(data.body)
+        .use(remarkParse)
+        .use(remarkGfm)
+        .use(remarkHtml)
+        .process(data.body)
 
       setChangelogHtml(html.value as string);
       setError(null);
@@ -84,7 +84,7 @@ function Content() {
       }}
     >
       <h2>Bazzite Release Notes</h2>
-      <div style={{ display: "flex", gap: "10px", marginBottom: "15px" }}>
+      <div style={{display: "flex", gap: "10px", marginBottom: "15px"}}>
         <button
           style={{
             padding: "10px 20px",
@@ -121,7 +121,7 @@ function Content() {
         </button>
       </div>
       {error ? (
-        <p style={{ color: "red" }} aria-live="polite">
+        <p style={{color: "red"}} aria-live="polite">
           {error}
         </p>
       ) : changelogHtml ? (
@@ -187,8 +187,8 @@ export default definePlugin(() => {
   return {
     name: "Bazzite Changelog Viewer",
     title: <div className={staticClasses.Title}>Bazzite Buddy</div>,
-    icon: <FaClipboardList />,
-    content: <Content />,
+    icon: <FaClipboardList/>,
+    content: <Content/>,
     onDismount() {
       patches.forEach(patch => {
         patch.unpatch();
-- 
cgit v1.2.3


From d97d5f11e7807906cff2cf41cad815fb05b0096c Mon Sep 17 00:00:00 2001
From: Victor Borges <victor1882@outlook.com>
Date: Sat, 3 May 2025 15:19:10 -0300
Subject: gets the correct branch now

---
 src/index.tsx | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

(limited to 'src/index.tsx')

diff --git a/src/index.tsx b/src/index.tsx
index 74af918..ed3327f 100755
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,12 +1,13 @@
 import {useEffect, useState} from "react";
 import {FaClipboardList} from "react-icons/fa";
-import {definePlugin} from "decky-frontend-lib";
 import remarkHtml from "remark-html"
 import remarkParse from "remark-parse"
 import remarkGfm from "remark-gfm"
 import {unified} from "unified"
 import {patchPartnerEventStore} from "./PartnerEventStorePatch";
 import {staticClasses} from "@decky/ui";
+import {definePlugin} from "@decky/api"
+import {fetchReleases} from "./FetchReleases";
 
 function Content() {
   const [changelogHtml, setChangelogHtml] = useState<string | null>(null);
@@ -14,25 +15,20 @@ function Content() {
   const [isRefreshing, setIsRefreshing] = useState<boolean>(false);
 
   const fetchChangelog = async (signal?: AbortSignal) => {
-    const url = "https://api.github.com/repos/ublue-os/bazzite/releases/latest";
     try {
-      const response = await fetch(url, {
-        headers: {
-          Accept: "application/vnd.github.v3+json",
-        },
-        signal,
-      });
+      const generator = fetchReleases(signal);
+      const iterator = await generator.next();
 
-      if (!response.ok) {
-        throw new Error(`Failed to fetch: ${response.statusText}`);
+      if (!iterator || iterator.done) {
+        setError("An unknown error occurred while fetching the changelog.");
+        return;
       }
 
-      const data = await response.json();
       const html = await unified()
         .use(remarkParse)
         .use(remarkGfm)
         .use(remarkHtml)
-        .process(data.body)
+        .process(iterator.value.body);
 
       setChangelogHtml(html.value as string);
       setError(null);
@@ -181,6 +177,7 @@ function Content() {
   );
 }
 
+// noinspection JSUnusedGlobalSymbols
 export default definePlugin(() => {
   const patches = patchPartnerEventStore();
 
-- 
cgit v1.2.3

