[Update] Config Page: Supporters: Update-able anytime.
Fetch the supporters data and images from the git repo, https://github.com/ShiinaSakamoto/vrct_supporters, via web.
This commit is contained in:
@@ -56,5 +56,9 @@ export { useHotkeys } from "./hotkeys/useHotkeys";
|
||||
export { useOscIpAddress } from "./advanced_settings/useOscIpAddress";
|
||||
export { useOscPort } from "./advanced_settings/useOscPort";
|
||||
|
||||
|
||||
export { useSupporters } from "./supporters/useSupporters";
|
||||
|
||||
|
||||
export { useSettingBoxScrollPosition } from "./useSettingBoxScrollPosition";
|
||||
export { useSoftwareVersion } from "./useSoftwareVersion";
|
||||
29
src-ui/logics/configs/supporters/useSupporters.jsx
Normal file
29
src-ui/logics/configs/supporters/useSupporters.jsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { useStore_SupportersData } from "@store";
|
||||
import { supporters_data_url } from "@ui_configs";
|
||||
export const useSupporters = () => {
|
||||
const { currentSupportersData, updateSupportersData, pendingSupportersData, errorSupportersData } = useStore_SupportersData();
|
||||
|
||||
const asyncFetchSupportersData = async () => {
|
||||
if (currentSupportersData.state === "pending") return;
|
||||
pendingSupportersData();
|
||||
try {
|
||||
const res = await fetch(supporters_data_url);
|
||||
// const res = await fetch(supporters_data_url, { cache: "no-store" });
|
||||
if (!res.ok) {
|
||||
throw new Error("Network response was not ok");
|
||||
}
|
||||
const data = await res.json();
|
||||
updateSupportersData(data);
|
||||
} catch (error) {
|
||||
console.error("Error fetching supporters' data:", error);
|
||||
errorSupportersData();
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
asyncFetchSupportersData,
|
||||
currentSupportersData,
|
||||
updateSupportersData,
|
||||
pendingSupportersData,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user