From 5e294936193b0309132512ae325adbe83401f65f Mon Sep 17 00:00:00 2001 From: bufan Date: Tue, 23 Jan 2024 18:03:37 +0800 Subject: [PATCH] reconstruct SyncingBotSaves component --- apps/u3/src/container/Save.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/u3/src/container/Save.tsx b/apps/u3/src/container/Save.tsx index de388da6..01e05665 100644 --- a/apps/u3/src/container/Save.tsx +++ b/apps/u3/src/container/Save.tsx @@ -52,11 +52,11 @@ const EmptyDesc = styled.span` export default function Save() { const { isFetching, personalFavors } = usePersonalFavors(); - const [syncNum, setSyncNum] = useState(0); + const [savedLink, setSavedLink] = useState([]); // console.log('personalFavors', personalFavors); const list = useMemo( - () => - uniqBy( + () => [ + ...uniqBy( personalFavors .filter((item) => !!item?.link && item.link.type !== 'test') .map((item) => { @@ -93,7 +93,12 @@ export default function Save() { }), 'id' ), - [personalFavors] + ...savedLink.map((item) => { + const createAt = item.createAt || new Date().getTime(); + return { ...item, createAt }; + }), + ], + [personalFavors, savedLink] ); const isEmpty = useMemo(() => list.length === 0, [list]); return ( @@ -102,7 +107,7 @@ export default function Save() { { console.log('onComplete SyncingBotSaves'); - setSyncNum(saves.length); + setSavedLink(saves); }} />