mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
fix(core): possible crash issues (#4783)
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user