Skip to content

Commit c68a1ae

Browse files
committed
refactor: optimize base list sorting by filtering out null entries
1 parent 085ca6f commit c68a1ae

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

apps/nextjs-app/src/features/app/blocks/space/BaseList.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ export const BaseList = (props: IBaseListProps) => {
3434
}, [allBaseList]);
3535

3636
const sortedList = useMemo(() => {
37-
const withTime = baseIds.map((baseId) => {
38-
const base = allBaseMap[baseId] || {};
39-
const lastVisitTime = lastVisitBaseMap[baseId]?.lastVisitTime;
40-
41-
return {
42-
...base,
43-
lastVisitTime,
44-
};
45-
});
37+
const withTime: (IGetBaseVo & { lastVisitTime?: string })[] = baseIds
38+
.map((baseId) => {
39+
const base = allBaseMap[baseId];
40+
if (!base) return null;
41+
const lastVisitTime = lastVisitBaseMap[baseId]?.lastVisitTime;
42+
return {
43+
...base,
44+
lastVisitTime,
45+
};
46+
})
47+
.filter((item) => item !== null);
4648

4749
/**
4850
* 1. Both have lastVisitTime: compare by lastVisitTime (recent first)

0 commit comments

Comments
 (0)