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]);
useEffect(() => {
memoStore.setLoadingStatus("incomplete");
}, []);
useEffect(() => {
if (!fetchMoreRef.current) return;

View File

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

View File

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

View File

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