chore: fix loading status

This commit is contained in:
Steven 2023-11-19 09:38:04 +08:00
parent 7f7ddf77b8
commit 94c71cb834
4 changed files with 13 additions and 2 deletions

View File

@ -82,6 +82,10 @@ const MemoList: React.FC = () => {
} }
}, [filter]); }, [filter]);
useEffect(() => {
memoStore.setLoadingStatus("incomplete");
}, []);
useEffect(() => { useEffect(() => {
if (!fetchMoreRef.current) return; if (!fetchMoreRef.current) return;

View File

@ -52,6 +52,10 @@ const Explore = () => {
.filter((m) => m.rowStatus === "NORMAL" && m.visibility !== "PRIVATE" && !m.parent) .filter((m) => m.rowStatus === "NORMAL" && m.visibility !== "PRIVATE" && !m.parent)
.sort((mi, mj) => mj.displayTs - mi.displayTs); .sort((mi, mj) => mj.displayTs - mi.displayTs);
useEffect(() => {
memoStore.setLoadingStatus("incomplete");
}, []);
useEffect(() => { useEffect(() => {
if (!fetchMoreRef.current) return; if (!fetchMoreRef.current) return;

View File

@ -2,7 +2,7 @@ import { omit } from "lodash-es";
import * as api from "@/helpers/api"; import * as api from "@/helpers/api";
import { DEFAULT_MEMO_LIMIT } from "@/helpers/consts"; import { DEFAULT_MEMO_LIMIT } from "@/helpers/consts";
import store, { useAppSelector } from "../"; import store, { useAppSelector } from "../";
import { updateLoadingStatus, createMemo, deleteMemo, patchMemo, upsertMemos } from "../reducer/memo"; import { updateLoadingStatus, createMemo, deleteMemo, patchMemo, upsertMemos, LoadingStatus } from "../reducer/memo";
import { useMemoCacheStore } from "../v1"; import { useMemoCacheStore } from "../v1";
export const convertResponseModelMemo = (memo: Memo): Memo => { export const convertResponseModelMemo = (memo: Memo): Memo => {
@ -82,6 +82,9 @@ export const useMemoStore = () => {
}); });
return archivedMemos; return archivedMemos;
}, },
setLoadingStatus: (status: LoadingStatus) => {
store.dispatch(updateLoadingStatus(status));
},
fetchMemoById, fetchMemoById,
getMemoById: async (memoId: MemoId) => { getMemoById: async (memoId: MemoId) => {
for (const m of state.memos) { for (const m of state.memos) {

View File

@ -1,7 +1,7 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { uniqBy } from "lodash-es"; import { uniqBy } from "lodash-es";
type LoadingStatus = "incomplete" | "fetching" | "complete"; export type LoadingStatus = "incomplete" | "fetching" | "complete";
interface State { interface State {
loadingStatus: LoadingStatus; loadingStatus: LoadingStatus;