mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 10:36:22 +08:00
fix(core): journal display on cmdk (#5723)

This commit is contained in:
@@ -2,8 +2,9 @@ import { assertExists } from '@blocksuite/global/utils';
|
||||
import type { Workspace } from '@blocksuite/store';
|
||||
import type { Atom } from 'jotai';
|
||||
import { atom, useAtomValue } from 'jotai';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { useJournalInfoHelper } from './use-journal';
|
||||
import { useJournalHelper, useJournalInfoHelper } from './use-journal';
|
||||
|
||||
const weakMap = new WeakMap<Workspace, Map<string, Atom<string>>>();
|
||||
|
||||
@@ -44,3 +45,20 @@ export function useBlockSuiteWorkspacePageTitle(
|
||||
);
|
||||
return localizedJournalDate || title;
|
||||
}
|
||||
|
||||
// This hook is NOT reactive to the page title change
|
||||
export function useGetBlockSuiteWorkspacePageTitle(
|
||||
blockSuiteWorkspace: Workspace
|
||||
) {
|
||||
const { getLocalizedJournalDateString } =
|
||||
useJournalHelper(blockSuiteWorkspace);
|
||||
return useCallback(
|
||||
(pageId: string) => {
|
||||
return (
|
||||
getLocalizedJournalDateString(pageId) ||
|
||||
blockSuiteWorkspace.getPage(pageId)?.meta.title
|
||||
);
|
||||
},
|
||||
[blockSuiteWorkspace, getLocalizedJournalDateString]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user