|
|
@@ -1,5 +1,5 @@
|
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
|
-import { getFetchStatus, getModules } from "@features/pageSlice";
|
|
|
+import { getFavoriteData, getFetchStatus, getModules } from "@features/pageSlice";
|
|
|
import { useThemeProvider } from "@contexts/themeContext";
|
|
|
import { Fragment, Suspense, useEffect } from "react";
|
|
|
import { reqPageModules } from "@features/api";
|
|
|
@@ -8,7 +8,7 @@ import AllWidgets from "@widgets/index";
|
|
|
import styles from "./styles.module.scss";
|
|
|
import LoadingIn from "@components/Loading/LoadingIn";
|
|
|
import Logo from '@components/Logo';
|
|
|
-import { useNavigate } from "react-router-dom";
|
|
|
+import { useLocation, useNavigate } from "react-router-dom";
|
|
|
import { ROUTE_PATH } from "@constants/routes";
|
|
|
import Button from "@mui/material/Button";
|
|
|
import Footer from "@layout/Footer";
|
|
|
@@ -414,10 +414,14 @@ const ModuleGroup = ({ pageID }) => {
|
|
|
const dispatch = useDispatch();
|
|
|
const status = useSelector(getFetchStatus);
|
|
|
const modules = useSelector(getModules(pageID));
|
|
|
+ const favoriteData = useSelector(getFavoriteData);
|
|
|
const { isMobile } = useThemeProvider();
|
|
|
+ const { pathname } = useLocation();
|
|
|
+ const requestedPageRef = useRef(null);
|
|
|
|
|
|
useEffect(() => {
|
|
|
- if (modules == null || modules.length === 0) {
|
|
|
+ if (modules == null && requestedPageRef.current !== pageID) {
|
|
|
+ requestedPageRef.current = pageID;
|
|
|
dispatch(reqPageModules(pageID));
|
|
|
}
|
|
|
}, [dispatch, modules, pageID]);
|
|
|
@@ -431,9 +435,22 @@ const ModuleGroup = ({ pageID }) => {
|
|
|
|
|
|
const renderModules = () => {
|
|
|
if (status === REQ_STATUS.IDLE) {
|
|
|
- if (modules == null) return (<></>);
|
|
|
- const hasHomeWithdraw = modules.some((item) => item.type === "ModuleHomeWithdraw");
|
|
|
- const hasSearch = modules.some((item) => item.type === "ModuleSearch");
|
|
|
+ let displayModules = modules;
|
|
|
+ if (pathname === ROUTE_PATH.FAVORITE && (!Array.isArray(displayModules) || displayModules.length === 0)) {
|
|
|
+ displayModules = [{
|
|
|
+ _mkey: `${pageID}_favorite`,
|
|
|
+ type: "ModuleGameList",
|
|
|
+ data_key: "favorite",
|
|
|
+ tabtype: 0,
|
|
|
+ page: 1,
|
|
|
+ totalPage: 1,
|
|
|
+ total: favoriteData.length,
|
|
|
+ data: favoriteData,
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ if (!Array.isArray(displayModules)) return (<></>);
|
|
|
+ const hasHomeWithdraw = displayModules.some((item) => item.type === "ModuleHomeWithdraw");
|
|
|
+ const hasSearch = displayModules.some((item) => item.type === "ModuleSearch");
|
|
|
const ModuleSidebar = AllWidgets["ModuleSidebar"];
|
|
|
const ModuleSearch = AllWidgets["ModuleSearch"];
|
|
|
|
|
|
@@ -455,7 +472,7 @@ const ModuleGroup = ({ pageID }) => {
|
|
|
<Suspense fallback={<LoadingIn />}>
|
|
|
<div className={`${styles.container} ${isMobile() ? '' : 'page-max-width-wrap'}`} >
|
|
|
{
|
|
|
- modules.map((item, index) => {
|
|
|
+ displayModules.map((item, index) => {
|
|
|
let Comp = AllWidgets[item.type];
|
|
|
if (Comp == null) {
|
|
|
console.warn(`Module type "${item.type}" not found in AllWidgets`);
|