fix(core): possible crash issues (#4783)
This commit is contained in:
1 parent
0ad0ab50d0
commit
f08408ebe5
3 files changed
+23
-10
No files matched your search
@@ -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