mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
feat(core): extract DocDisplayMetaService to resolve doc icon/title (#8226)
AF-1315
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { IconButton, MobileMenu } from '@affine/component';
|
||||
import { useJournalInfoHelper } from '@affine/core/components/hooks/use-journal';
|
||||
import { EditorJournalPanel } from '@affine/core/desktop/pages/workspace/detail-page/tabs/journal';
|
||||
import { TodayIcon, TomorrowIcon, YesterdayIcon } from '@blocksuite/icons/rc';
|
||||
import { useService, WorkspaceService } from '@toeverything/infra';
|
||||
import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
|
||||
export const JournalIconButton = ({
|
||||
docId,
|
||||
@@ -11,18 +11,14 @@ export const JournalIconButton = ({
|
||||
docId: string;
|
||||
className?: string;
|
||||
}) => {
|
||||
const workspace = useService(WorkspaceService).workspace;
|
||||
const { journalDate, isJournal } = useJournalInfoHelper(
|
||||
workspace.docCollection,
|
||||
docId
|
||||
const { isJournal } = useJournalInfoHelper(docId);
|
||||
|
||||
const docDisplayMetaService = useService(DocDisplayMetaService);
|
||||
const Icon = useLiveData(
|
||||
docDisplayMetaService.icon$(docId, {
|
||||
compareDate: new Date(),
|
||||
})
|
||||
);
|
||||
const Icon = journalDate
|
||||
? journalDate.isBefore(new Date(), 'day')
|
||||
? YesterdayIcon
|
||||
: journalDate.isAfter(new Date(), 'day')
|
||||
? TomorrowIcon
|
||||
: TodayIcon
|
||||
: TodayIcon;
|
||||
|
||||
if (!isJournal) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user