fix: regression on the database and bookmark block (#2737)

This commit is contained in:
Himself65
2023-06-09 11:29:52 +08:00
committed by GitHub
parent 1971749449
commit bf6af934f6
4 changed files with 12 additions and 16 deletions

View File

@@ -19,7 +19,6 @@ import { createIndexedDBBackgroundProvider } from '@affine/workspace/providers';
import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils'; import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils';
import { nanoid } from '@blocksuite/store'; import { nanoid } from '@blocksuite/store';
import { setEditorFlags } from '../../utils/editor-flag';
import { import {
BlockSuitePageList, BlockSuitePageList,
PageDetailEditor, PageDetailEditor,
@@ -44,7 +43,6 @@ export const LocalAdapter: WorkspaceAdapter<WorkspaceFlavour.LOCAL> = {
const page = blockSuiteWorkspace.createPage({ const page = blockSuiteWorkspace.createPage({
id: DEFAULT_HELLO_WORLD_PAGE_ID, id: DEFAULT_HELLO_WORLD_PAGE_ID,
}); });
setEditorFlags(blockSuiteWorkspace);
if (config.enablePreloading) { if (config.enablePreloading) {
initPageWithPreloading(page).catch(err => { initPageWithPreloading(page).catch(err => {
logger.error('init page with preloading failed', err); logger.error('init page with preloading failed', err);

View File

@@ -64,7 +64,6 @@ import {
} from '../providers/modal-provider'; } from '../providers/modal-provider';
import { pathGenerator, publicPathGenerator } from '../shared'; import { pathGenerator, publicPathGenerator } from '../shared';
import { toast } from '../utils'; import { toast } from '../utils';
import { setEditorFlags } from '../utils/editor-flag';
const QuickSearchModal = lazy(() => const QuickSearchModal = lazy(() =>
import('../components/pure/quick-search-modal').then(module => ({ import('../components/pure/quick-search-modal').then(module => ({
@@ -311,7 +310,6 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {
id: pageId, id: pageId,
}); });
assertEquals(page.id, pageId); assertEquals(page.id, pageId);
setEditorFlags(currentWorkspace.blockSuiteWorkspace);
if (config.enablePreloading) { if (config.enablePreloading) {
initPageWithPreloading(page).catch(error => { initPageWithPreloading(page).catch(error => {
console.error('import error:', error); console.error('import error:', error);

View File

@@ -1,12 +0,0 @@
import { type BlockSuiteFeatureFlags, config } from '@affine/env';
import type { BlockSuiteWorkspace } from '../shared';
export function setEditorFlags(blockSuiteWorkspace: BlockSuiteWorkspace) {
Object.entries(config.editorFlags).forEach(([key, value]) => {
blockSuiteWorkspace.awarenessStore.setFlag(
key as keyof BlockSuiteFeatureFlags,
value
);
});
}

View File

@@ -1,3 +1,5 @@
import type { BlockSuiteFeatureFlags } from '@affine/env';
import { config } from '@affine/env';
import { WorkspaceFlavour } from '@affine/env/workspace'; import { WorkspaceFlavour } from '@affine/env/workspace';
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models'; import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
import type { Generator, StoreOptions } from '@blocksuite/store'; import type { Generator, StoreOptions } from '@blocksuite/store';
@@ -14,6 +16,15 @@ export function cleanupWorkspace(flavour: WorkspaceFlavour) {
); );
} }
function setEditorFlags(workspace: Workspace) {
Object.entries(config.editorFlags).forEach(([key, value]) => {
workspace.awarenessStore.setFlag(
key as keyof BlockSuiteFeatureFlags,
value
);
});
}
const hashMap = new Map<string, Workspace>(); const hashMap = new Map<string, Workspace>();
/** /**
@@ -86,6 +97,7 @@ export function createEmptyBlockSuiteWorkspace(
}) })
.register(AffineSchemas) .register(AffineSchemas)
.register(__unstableSchemas); .register(__unstableSchemas);
setEditorFlags(workspace);
hashMap.set(cacheKey, workspace); hashMap.set(cacheKey, workspace);
return workspace; return workspace;
} }