FIX: Fetching of changelog files for changelog modal

FR this time, I HOPE
This commit is contained in:
Kentai Radiquum 2024-08-12 04:17:17 +05:00
parent ff99b1db4c
commit 4af7a2a632
Signed by: Radiquum
GPG key ID: 858E8EE696525EED

View file

@ -5,11 +5,6 @@ import Markdown from "markdown-to-jsx";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import Styles from "./ChangelogModal.module.css"; import Styles from "./ChangelogModal.module.css";
async function _fetchVersionChangelog(version: string) {
const res = await fetch(`/changelog/${version}.md`);
return await res.text();
}
export const ChangelogModal = (props: { export const ChangelogModal = (props: {
isOpen: boolean; isOpen: boolean;
setIsOpen: any; setIsOpen: any;
@ -21,8 +16,13 @@ export const ChangelogModal = (props: {
Record<string, string> Record<string, string>
>({}); >({});
async function _fetchVersionChangelog(version: string) {
const res = await fetch(`/changelog/${version}.md`);
return await res.text();
}
useEffect(() => { useEffect(() => {
if (props.version != "") { if (props.version != "" && currentVersionChangelog == "") {
_fetchVersionChangelog(props.version).then((data) => { _fetchVersionChangelog(props.version).then((data) => {
setCurrentVersionChangelog(data); setCurrentVersionChangelog(data);
}); });
@ -40,13 +40,10 @@ export const ChangelogModal = (props: {
}); });
}); });
} }
}, []); }, [props.version]);
return ( return (
<Modal <Modal show={props.isOpen} onClose={() => props.setIsOpen(false)}>
show={props.isOpen}
onClose={() => props.setIsOpen(false)}
>
<Modal.Header>Список изменений v{props.version}</Modal.Header> <Modal.Header>Список изменений v{props.version}</Modal.Header>
<Modal.Body> <Modal.Body>
<Markdown className={Styles.markdown}> <Markdown className={Styles.markdown}>