Skip to content

Commit

Permalink
fix: Fetch changelog every time when the page is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
NriotHrreion committed Sep 29, 2023
1 parent 0c83050 commit 83fb213
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/dialogs/AboutDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { ReactElement, forwardRef, useState, useId } from "react";
import { InlineMath } from "react-katex";

import Emitter from "@/utils/Emitter";
import type { PropsWithRef } from "@/types";
import { version } from "@/global";

Expand Down Expand Up @@ -99,7 +100,13 @@ const AboutDialog: React.FC<AboutDialogProps> = forwardRef<Dialog, AboutDialogPr
<p><img src="/icon.png" alt="icon" width={18}/> <b>Calcium</b> 是一个由React+Typescript编写的基于web的网页计算器.</p>

<ul>
<li><AboutItem name="版本" content={<button onClick={() => setReleasesVisible(true)}>{version}</button>}/></li>
<li><AboutItem name="版本" content={
<button onClick={() => {
setReleasesVisible(true);
Emitter.get().emit("release-indialog-open")}}>
{version}
</button>
}/></li>
<li><AboutItem name="作者" content="NoahHrreion"/></li>
<li><AboutItem name="数学显示" content={<a href="https://katex.org" target="_blank" rel="noreferrer" className="katex-logo"><InlineMath>\KaTeX</InlineMath></a>}/></li>
<li><AboutItem name="支持我" content={<a href="https://nin.red/#/donate" target="_blank" rel="noreferrer">打赏</a>}/></li>
Expand Down
21 changes: 13 additions & 8 deletions src/dialogs/ReleasesIndialogPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { useState, useEffect } from "react";
import React, { useState } from "react";
import ReactMarkdown from "react-markdown";
import Axios from "axios";

import useEmitter from "@/hooks/useEmitter";
import { RepoReleaseResponse } from "@/types";
import Logger from "@/utils/Logger";

Expand All @@ -14,13 +15,17 @@ const ReleasesIndialogPage: React.FC = () => {
window.open(releaseItem.html_url);
};

useEffect(() => {
Axios.get<RepoReleaseResponse[]>(fetchURL).then((res) => {
setList(res.data);
}).catch((err) => {
Logger.error("Axios cannot fetch release list from Github, ERROR: "+ err);
});
}, []);
useEmitter([
["release-indialog-open", () => {
if(list) return;

Axios.get<RepoReleaseResponse[]>(fetchURL).then((res) => {
setList(res.data);
}).catch((err) => {
Logger.error("Axios cannot fetch release list from Github, ERROR: "+ err);
});
}]
]);

return (
<div className="release-list">
Expand Down

1 comment on commit 83fb213

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.