@@ -147,15 +156,12 @@ const EditorJournalPanel = (props: EditorExtensionProps) => {
};
const sortPagesByDate = (
- pages: Page[],
+ pages: PageMeta[],
field: 'updatedDate' | 'createDate',
order: 'asc' | 'desc' = 'desc'
) => {
return [...pages].sort((a, b) => {
- return (
- (order === 'asc' ? 1 : -1) *
- dayjs(b.meta[field]).diff(dayjs(a.meta[field]))
- );
+ return (order === 'asc' ? 1 : -1) * dayjs(b[field]).diff(dayjs(a[field]));
});
};
@@ -174,21 +180,21 @@ const JournalDailyCountBlock = ({ workspace, date }: JournalBlockProps) => {
const nodeRef = useRef
(null);
const t = useAFFiNEI18N();
const [activeItem, setActiveItem] = useState('createdToday');
+ const pageMetas = useBlockSuitePageMeta(workspace);
const navigateHelper = useNavigateHelper();
const getTodaysPages = useCallback(
(field: 'createDate' | 'updatedDate') => {
- const pages: Page[] = [];
- Array.from(workspace.pages.values()).forEach(page => {
- if (page.meta.trash) return;
- if (page.meta[field] && dayjs(page.meta[field]).isSame(date, 'day')) {
- pages.push(page);
- }
- });
- return sortPagesByDate(pages, field);
+ return sortPagesByDate(
+ pageMetas.filter(pageMeta => {
+ if (pageMeta.trash) return false;
+ return pageMeta[field] && dayjs(pageMeta[field]).isSame(date, 'day');
+ }),
+ field
+ );
},
- [date, workspace.pages]
+ [date, pageMetas]
);
const createdToday = useMemo(
@@ -257,14 +263,15 @@ const JournalDailyCountBlock = ({ workspace, date }: JournalBlockProps) => {
- {renderList.map((page, index) => (
+ {renderList.map((pageMeta, index) => (
- navigateHelper.openPage(workspace.id, page.id)
+ navigateHelper.openPage(workspace.id, pageMeta.id)
}
tabIndex={name === activeItem ? 0 : -1}
key={index}
- page={page}
+ pageMeta={pageMeta}
+ workspace={workspace}
/>
))}
@@ -315,7 +322,8 @@ const ConflictList = ({