|
|
|
@ -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 { createMemo, deleteMemo, patchMemo, setIsFetching, upsertMemos } from "../reducer/memo";
|
|
|
|
|
import { createMemo, deleteMemo, patchMemo, upsertMemos } from "../reducer/memo";
|
|
|
|
|
import { useMemoCacheStore } from "../v1";
|
|
|
|
|
import { useUserStore } from "./";
|
|
|
|
|
|
|
|
|
@ -34,7 +34,6 @@ export const useMemoStore = () => {
|
|
|
|
|
return store.getState().memo;
|
|
|
|
|
},
|
|
|
|
|
fetchMemos: async (limit = DEFAULT_MEMO_LIMIT, offset = 0) => {
|
|
|
|
|
store.dispatch(setIsFetching(true));
|
|
|
|
|
const memoFind: MemoFind = {
|
|
|
|
|
rowStatus: "NORMAL",
|
|
|
|
|
limit,
|
|
|
|
@ -46,26 +45,20 @@ export const useMemoStore = () => {
|
|
|
|
|
const { data } = await api.getMemoList(memoFind);
|
|
|
|
|
const fetchedMemos = data.map((m) => convertResponseModelMemo(m));
|
|
|
|
|
store.dispatch(upsertMemos(fetchedMemos));
|
|
|
|
|
store.dispatch(setIsFetching(false));
|
|
|
|
|
|
|
|
|
|
for (const m of fetchedMemos) {
|
|
|
|
|
memoCacheStore.setMemoCache(m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fetchedMemos;
|
|
|
|
|
},
|
|
|
|
|
fetchAllMemos: async (limit = DEFAULT_MEMO_LIMIT, offset?: number) => {
|
|
|
|
|
store.dispatch(setIsFetching(true));
|
|
|
|
|
const memoFind: MemoFind = {
|
|
|
|
|
rowStatus: "NORMAL",
|
|
|
|
|
limit,
|
|
|
|
|
offset,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const { data } = await api.getAllMemos(memoFind);
|
|
|
|
|
const fetchedMemos = data.map((m) => convertResponseModelMemo(m));
|
|
|
|
|
store.dispatch(upsertMemos(fetchedMemos));
|
|
|
|
|
store.dispatch(setIsFetching(false));
|
|
|
|
|
|
|
|
|
|
for (const m of fetchedMemos) {
|
|
|
|
|
memoCacheStore.setMemoCache(m);
|
|
|
|
|