fix(core): possible crash issues (#4783)

This commit is contained in:
Peng Xiao
2023-10-31 16:56:14 +08:00
committed by GitHub
parent 0ad0ab50d0
commit f08408ebe5
3 changed files with 23 additions and 10 deletions

View File

@@ -17,8 +17,12 @@ export const getPagePreviewText = (page: Page) => {
return text.slice(0, 300);
};
export function useBlockSuitePagePreview(page: Page): Atom<string> {
if (weakMap.has(page)) {
const emptyAtom = atom<string>('');
export function useBlockSuitePagePreview(page: Page | null): Atom<string> {
if (page === null) {
return emptyAtom;
} else if (weakMap.has(page)) {
return weakMap.get(page) as Atom<string>;
} else {
const baseAtom = atom<string>(getPagePreviewText(page));