There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: disable sqlite provider (#2888)
Peng Xiao79b3b1dabc7a
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 9d9a686c66..5380b36621 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -92,6 +92,7 @@ jobs:ENABLE_LEGACY_PROVIDER: trueENABLE_PRELOADING: falseENABLE_NEW_SETTING_MODAL: false+ ENABLE_SQLITE_PROVIDER: falsesteps:- uses: actions/checkout@v3diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.ymlindex b3e7fc8f97..24bc9d6d42 100644--- a/.github/workflows/nightly-build.yml+++ b/.github/workflows/nightly-build.yml@@ -61,6 +61,7 @@ jobs:API_SERVER_PROFILE: prodENABLE_TEST_PROPERTIES: falseENABLE_BOOKMARK_OPERATION: true+ ENABLE_SQLITE_PROVIDER: falseRELEASE_VERSION: ${{ needs.set-build-version.outputs.version }}- name: Upload Artifact (web-static)diff --git a/.github/workflows/release-desktop-app.yml b/.github/workflows/release-desktop-app.ymlindex bc0f789bc2..1b094c5525 100644--- a/.github/workflows/release-desktop-app.yml+++ b/.github/workflows/release-desktop-app.yml@@ -57,6 +57,7 @@ jobs:API_SERVER_PROFILE: prodENABLE_TEST_PROPERTIES: falseENABLE_BOOKMARK_OPERATION: true+ ENABLE_SQLITE_PROVIDER: falseRELEASE_VERSION: ${{ github.event.inputs.version }}- name: Upload Artifact (web-static)diff --git a/apps/electron/tests/workspace.spec.ts b/apps/electron/tests/workspace.spec.tsindex 247e45ceaf..8621d86f08 100644--- a/apps/electron/tests/workspace.spec.ts+++ b/apps/electron/tests/workspace.spec.ts@@ -5,7 +5,7 @@ import fs from 'fs-extra';import { test } from './fixture';-test('check workspace has a DB file', async ({ appInfo, workspace }) => {+test.skip('check workspace has a DB file', async ({ appInfo, workspace }) => {const w = await workspace.current();const dbPath = path.join(appInfo.sessionData,@@ -17,7 +17,7 @@ test('check workspace has a DB file', async ({ appInfo, workspace }) => {expect(await fs.exists(dbPath)).toBe(true);});-test('move workspace db file', async ({ page, appInfo, workspace }) => {+test.skip('move workspace db file', async ({ page, appInfo, workspace }) => {const w = await workspace.current();const settingButton = page.getByTestId('slider-bar-workspace-setting-button');// goto settings@@ -42,7 +42,7 @@ test('move workspace db file', async ({ page, appInfo, workspace }) => {expect(files.some(f => f.endsWith('.affine'))).toBe(true);});-test('export then add', async ({ page, appInfo, workspace }) => {+test.skip('export then add', async ({ page, appInfo, workspace }) => {const w = await workspace.current();const settingButton = page.getByTestId('slider-bar-workspace-setting-button');// goto settingsdiff --git a/apps/web/preset.config.mjs b/apps/web/preset.config.mjsindex d4d198c3d6..7350ec4bf0 100644--- a/apps/web/preset.config.mjs+++ b/apps/web/preset.config.mjs@@ -30,21 +30,12 @@ export const buildFlags = {enableLegacyCloud: process.env.ENABLE_LEGACY_PROVIDER? process.env.ENABLE_LEGACY_PROVIDER === 'true': true,- enableBroadcastChannelProvider: Boolean(- process.env.ENABLE_BC_PROVIDER ?? '1'- ),- enableDebugPage: Boolean(- process.env.ENABLE_DEBUG_PAGE ?? process.env.NODE_ENV === 'development'- ),+ enableBroadcastChannelProvider: process.env.ENABLE_BC_PROVIDER !== 'false',+ enableDebugPage: true,changelogUrl:process.env.CHANGELOG_URL ??'https://affine.pro/blog/what-is-new-affine-0620',- enablePreloading:- process.env.ENABLE_PRELOADING === undefined- ? true- : process.env.ENABLE_PRELOADING === 'true',- enableNewSettingModal:- process.env.ENABLE_NEW_SETTING_MODAL === undefined- ? true- : process.env.ENABLE_PRELOADING === 'true',+ enablePreloading: process.env.ENABLE_PRELOADING === 'true',+ enableNewSettingModal: process.env.ENABLE_NEW_SETTING_MODAL === 'true',+ enableSQLiteProvider: process.env.ENABLE_SQLITE_PROVIDER === 'true',};diff --git a/apps/web/src/atoms/index.ts b/apps/web/src/atoms/index.tsindex 02235d1416..c2c3e6787e 100644--- a/apps/web/src/atoms/index.ts+++ b/apps/web/src/atoms/index.ts@@ -1,4 +1,5 @@import { DebugLogger } from '@affine/debug';+import { config } from '@affine/env';import { WorkspaceFlavour, WorkspaceVersion } from '@affine/env/workspace';import type { RootWorkspaceMetadataV2 } from '@affine/workspace/atom';import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';@@ -52,7 +53,7 @@ rootWorkspacesMetadataAtom.onMount = setAtom => {}, 0);}- if (environment.isDesktop) {+ if (environment.isDesktop && config.enableSQLiteProvider) {window.apis?.workspace.list().then(workspaceIDs => {diff --git a/apps/web/src/components/affine/create-workspace-modal/index.tsx b/apps/web/src/components/affine/create-workspace-modal/index.tsxindex 5f361f02c6..f95dd3b465 100644--- a/apps/web/src/components/affine/create-workspace-modal/index.tsx+++ b/apps/web/src/components/affine/create-workspace-modal/index.tsx@@ -290,7 +290,11 @@ export const CreateWorkspaceModal = ({console.error(err);});} else if (mode === 'new') {- setStep(environment.isDesktop ? 'set-db-location' : 'name-workspace');+ setStep(+ environment.isDesktop && config.enableSQLiteProvider+ ? 'set-db-location'+ : 'name-workspace'+ );} else {setStep(undefined);}@@ -342,7 +346,7 @@ export const CreateWorkspaceModal = ({const onConfirmName = useCallback((name: string) => {setWorkspaceName(name);- if (environment.isDesktop) {+ if (environment.isDesktop && config.enableSQLiteProvider) {setStep('set-syncing-mode');} else {// this will be the last step for web for nowdiff --git a/apps/web/src/components/affine/workspace-setting-detail/panel/export/index.tsx b/apps/web/src/components/affine/workspace-setting-detail/panel/export/index.tsxindex 50682ee950..67f9e25c2f 100644--- a/apps/web/src/components/affine/workspace-setting-detail/panel/export/index.tsx+++ b/apps/web/src/components/affine/workspace-setting-detail/panel/export/index.tsx@@ -1,4 +1,5 @@import { Button, toast, Wrapper } from '@affine/component';+import { config } from '@affine/env';import { useAFFiNEI18N } from '@affine/i18n/hooks';import { rootCurrentWorkspaceIdAtom } from '@affine/workspace/atom';import { useAtomValue } from 'jotai';@@ -12,7 +13,7 @@ export const ExportPanel = () => {<Buttontype="light"shape="circle"- disabled={!environment.isDesktop || !id}+ disabled={!environment.isDesktop || !id || !config.enableSQLiteProvider}data-testid="export-affine-backup"onClick={async () => {if (id) {diff --git a/apps/web/src/components/affine/workspace-setting-detail/panel/general/index.tsx b/apps/web/src/components/affine/workspace-setting-detail/panel/general/index.tsxindex fe3d68f3ad..c52bea6fe3 100644--- a/apps/web/src/components/affine/workspace-setting-detail/panel/general/index.tsx+++ b/apps/web/src/components/affine/workspace-setting-detail/panel/general/index.tsx@@ -1,5 +1,6 @@import { Button, toast } from '@affine/component';import { WorkspaceAvatar } from '@affine/component/workspace-avatar';+import { config } from '@affine/env';import { useAFFiNEI18N } from '@affine/i18n/hooks';import {ArrowRightSmallIcon,@@ -26,7 +27,12 @@ import { StyledInput } from './style';const useShowOpenDBFile = (workspaceId: string) => {const [show, setShow] = useState(false);useEffect(() => {- if (window.apis && window.events && environment.isDesktop) {+ if (+ window.apis &&+ window.events &&+ environment.isDesktop &&+ config.enableSQLiteProvider+ ) {window.apis.workspace.getMeta(workspaceId).then(meta => {@@ -137,7 +143,9 @@ export const GeneralPanel: React.FC<PanelProps> = ({</Button></div></div>- <DesktopClientOnly workspaceId={workspace.id} />+ {environment.isDesktop && config.enableSQLiteProvider ? (+ <DesktopClientOnly workspaceId={workspace.id} />+ ) : null}<div className={style.row}><div className={style.col}><div className={style.settingItemLabel}>@@ -201,7 +209,7 @@ function DesktopClientOnly({ workspaceId }: { workspaceId: string }) {const t = useAFFiNEI18N();const showOpenFolder = useShowOpenDBFile(workspaceId);const onRevealDBFile = useCallback(() => {- if (environment.isDesktop) {+ if (environment.isDesktop && config.enableSQLiteProvider) {window.apis?.dialog.revealDBFile(workspaceId).catch(err => {console.error(err);});diff --git a/apps/web/src/components/pure/workspace-list-modal/index.tsx b/apps/web/src/components/pure/workspace-list-modal/index.tsxindex 7ef3c40cc6..8de48fec6f 100644--- a/apps/web/src/components/pure/workspace-list-modal/index.tsx+++ b/apps/web/src/components/pure/workspace-list-modal/index.tsx@@ -8,6 +8,7 @@ import {} from '@affine/component';import { ScrollableContainer } from '@affine/component';import { WorkspaceList } from '@affine/component/workspace-list';+import { config } from '@affine/env/config';import type {AffineLegacyCloudWorkspace,LocalWorkspace,@@ -55,6 +56,107 @@ interface WorkspaceModalProps {onMoveWorkspace: (activeId: string, overId: string) => void;}+const CreateWorkspaceCard = ({+ onNewWorkspace,+ onAddWorkspace,+}: {+ onNewWorkspace: () => void;+ onAddWorkspace: () => void;+}) => {+ const t = useAFFiNEI18N();+ const anchorEL = useRef<HTMLDivElement>(null);++ if (config.enableSQLiteProvider && environment.isDesktop) {+ return (+ <Menu+ placement="auto"+ trigger={['click']}+ zIndex={1000}+ content={+ <StyledCreateWorkspaceCardPillContainer>+ <StyledCreateWorkspaceCardPill>+ <MenuItem+ style={{+ height: 'auto',+ padding: '8px 12px',+ }}+ onClick={onNewWorkspace}+ data-testid="new-workspace"+ >+ <StyledCreateWorkspaceCardPillContent>+ <div>+ <p>{t['New Workspace']()}</p>+ <StyledCreateWorkspaceCardPillTextSecondary>+ <p>{t['Create your own workspace']()}</p>+ </StyledCreateWorkspaceCardPillTextSecondary>+ </div>+ <StyledCreateWorkspaceCardPillIcon>+ <PlusIcon />+ </StyledCreateWorkspaceCardPillIcon>+ </StyledCreateWorkspaceCardPillContent>+ </MenuItem>+ </StyledCreateWorkspaceCardPill>+ <StyledCreateWorkspaceCardPill>+ <MenuItem+ onClick={onAddWorkspace}+ data-testid="add-workspace"+ style={{+ height: 'auto',+ padding: '8px 12px',+ }}+ >+ <StyledCreateWorkspaceCardPillContent>+ <div>+ <p>{t['Add Workspace']()}</p>+ <StyledCreateWorkspaceCardPillTextSecondary>+ <p>{t['Add Workspace Hint']()}</p>+ </StyledCreateWorkspaceCardPillTextSecondary>+ </div>+ <StyledCreateWorkspaceCardPillIcon>+ <ImportIcon />+ </StyledCreateWorkspaceCardPillIcon>+ </StyledCreateWorkspaceCardPillContent>+ </MenuItem>+ </StyledCreateWorkspaceCardPill>+ </StyledCreateWorkspaceCardPillContainer>+ }+ >+ <StyledCreateWorkspaceCard+ ref={anchorEL}+ data-testid="add-or-new-workspace"+ >+ <StyleWorkspaceAdd className="add-icon">+ <PlusIcon />+ </StyleWorkspaceAdd>++ <StyleWorkspaceInfo>+ <StyleWorkspaceTitle>{t['New Workspace']()}</StyleWorkspaceTitle>+ <p>{t['Create Or Import']()}</p>+ </StyleWorkspaceInfo>+ </StyledCreateWorkspaceCard>+ </Menu>+ );+ } else {+ return (+ <div>+ <StyledCreateWorkspaceCard+ onClick={onNewWorkspace}+ data-testid="new-workspace"+ >+ <StyleWorkspaceAdd className="add-icon">+ <PlusIcon />+ </StyleWorkspaceAdd>++ <StyleWorkspaceInfo>+ <StyleWorkspaceTitle>{t['New Workspace']()}</StyleWorkspaceTitle>+ <p>{t['Create Or Import']()}</p>+ </StyleWorkspaceInfo>+ </StyledCreateWorkspaceCard>+ </div>+ );+ }+};+export const WorkspaceListModal = ({disabled,open,@@ -71,7 +173,6 @@ export const WorkspaceListModal = ({onMoveWorkspace,}: WorkspaceModalProps) => {const t = useAFFiNEI18N();- const anchorEL = useRef<HTMLDivElement>(null);return (<Modal open={open} onClose={onClose}><ModalWrapper@@ -128,98 +229,10 @@ export const WorkspaceListModal = ({[onMoveWorkspace])}/>- {!environment.isDesktop && (- <div>- <StyledCreateWorkspaceCard- onClick={onNewWorkspace}- data-testid="new-workspace"- >- <StyleWorkspaceAdd className="add-icon">- <PlusIcon />- </StyleWorkspaceAdd>-- <StyleWorkspaceInfo>- <StyleWorkspaceTitle>- {t['New Workspace']()}- </StyleWorkspaceTitle>- <p>{t['Create Or Import']()}</p>- </StyleWorkspaceInfo>- </StyledCreateWorkspaceCard>- </div>- )}-- {environment.isDesktop && (- <Menu- placement="auto"- trigger={['click']}- zIndex={1000}- content={- <StyledCreateWorkspaceCardPillContainer>- <StyledCreateWorkspaceCardPill>- <MenuItem- style={{- height: 'auto',- padding: '8px 12px',- }}- onClick={onNewWorkspace}- data-testid="new-workspace"- >- <StyledCreateWorkspaceCardPillContent>- <div>- <p>{t['New Workspace']()}</p>- <StyledCreateWorkspaceCardPillTextSecondary>- <p>{t['Create your own workspace']()}</p>- </StyledCreateWorkspaceCardPillTextSecondary>- </div>- <StyledCreateWorkspaceCardPillIcon>- <PlusIcon />- </StyledCreateWorkspaceCardPillIcon>- </StyledCreateWorkspaceCardPillContent>- </MenuItem>- </StyledCreateWorkspaceCardPill>- <StyledCreateWorkspaceCardPill>- <MenuItem- disabled={!environment.isDesktop}- onClick={onAddWorkspace}- data-testid="add-workspace"- style={{- height: 'auto',- padding: '8px 12px',- }}- >- <StyledCreateWorkspaceCardPillContent>- <div>- <p>{t['Add Workspace']()}</p>- <StyledCreateWorkspaceCardPillTextSecondary>- <p>{t['Add Workspace Hint']()}</p>- </StyledCreateWorkspaceCardPillTextSecondary>- </div>- <StyledCreateWorkspaceCardPillIcon>- <ImportIcon />- </StyledCreateWorkspaceCardPillIcon>- </StyledCreateWorkspaceCardPillContent>- </MenuItem>- </StyledCreateWorkspaceCardPill>- </StyledCreateWorkspaceCardPillContainer>- }- >- <StyledCreateWorkspaceCard- ref={anchorEL}- data-testid="add-or-new-workspace"- >- <StyleWorkspaceAdd className="add-icon">- <PlusIcon />- </StyleWorkspaceAdd>-- <StyleWorkspaceInfo>- <StyleWorkspaceTitle>- {t['New Workspace']()}- </StyleWorkspaceTitle>- <p>{t['Create Or Import']()}</p>- </StyleWorkspaceInfo>- </StyledCreateWorkspaceCard>- </Menu>- )}+ <CreateWorkspaceCard+ onNewWorkspace={onNewWorkspace}+ onAddWorkspace={onAddWorkspace}+ /></StyledModalContent></ScrollableContainer><Footer user={user} onLogin={onClickLogin} onLogout={onClickLogout} />diff --git a/nx.json b/nx.jsonindex 1f66ae0b28..0f9d542ce7 100644--- a/nx.json+++ b/nx.json@@ -71,6 +71,9 @@},{"env": "API_SERVER_PROFILE"+ },+ {+ "env": "ENABLE_SQLITE_PROVIDER"}]},diff --git a/packages/env/src/config.ts b/packages/env/src/config.tsindex 54fb3d72d5..e1bdfc3b83 100644--- a/packages/env/src/config.ts+++ b/packages/env/src/config.ts@@ -48,6 +48,7 @@ export const buildFlagsSchema = z.object({changelogUrl: z.string(),enablePreloading: z.boolean(),enableNewSettingModal: z.boolean(),+ enableSQLiteProvider: z.boolean(),});export const blockSuiteFeatureFlags = z.object({diff --git a/packages/workspace/src/local/crud.ts b/packages/workspace/src/local/crud.tsindex 7a0d05a697..71635df85c 100644--- a/packages/workspace/src/local/crud.ts+++ b/packages/workspace/src/local/crud.ts@@ -1,4 +1,5 @@import { DebugLogger } from '@affine/debug';+import { config } from '@affine/env';import type { LocalWorkspace, WorkspaceCRUD } from '@affine/env/workspace';import { WorkspaceFlavour } from '@affine/env/workspace';import { nanoid, Workspace as BlockSuiteWorkspace } from '@blocksuite/store';@@ -111,7 +112,7 @@ export const CRUD: WorkspaceCRUD<WorkspaceFlavour.LOCAL> = {: [];// workspaces in desktop- if (window.apis && environment.isDesktop) {+ if (window.apis && environment.isDesktop && config.enableSQLiteProvider) {const desktopIds = (await window.apis.workspace.list()).map(([id]) => id);// the ids maybe a subset of the local storageconst moreWorkspaces = desktopIds.filter(diff --git a/packages/workspace/src/providers/index.ts b/packages/workspace/src/providers/index.tsindex 713e0fa076..f95c2e0932 100644--- a/packages/workspace/src/providers/index.ts+++ b/packages/workspace/src/providers/index.ts@@ -173,7 +173,7 @@ export const createLocalProviders = (): DocProviderCreator[] => {providers.push(createBroadcastChannelProvider);}- if (environment.isDesktop) {+ if (environment.isDesktop && config.enableSQLiteProvider) {providers.push(createSQLiteProvider, createSQLiteDBDownloadProvider);}