Skip to content

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.

1.adjust export/import database;

mitsuha14a3cdff41fc
diff --git a/libs/components/layout/src/header/FileSystem.tsx b/libs/components/layout/src/header/FileSystem.tsx
index 30c2b68816..c143e6f3f1 100644
--- a/libs/components/layout/src/header/FileSystem.tsx
+++ b/libs/components/layout/src/header/FileSystem.tsx
@@ -80,34 +80,20 @@ export const FileSystem = () => {
if (apiSupported && !selected) {
return (
- <>
- <MuiSnackbar
- anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
- open={error}
- message="Request File Permission failed, please check if you have permission"
- sx={{ marginTop: '3em' }}
- action={
- <IconButton
- aria-label="close"
- onClick={() => setError(false)}
- >
- <CloseIcon />
- </IconButton>
- }
- />
- <StyledFileSystem
- onClick={async () => {
- try {
- await requestPermission('AFFiNE');
- onSelected();
- } catch (e) {
- onError();
- }
- }}
- >
- {t('Sync to Disk')}
- </StyledFileSystem>
- </>
+ <MuiSnackbar
+ anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
+ open={error}
+ message="Request File Permission failed, please check if you have permission"
+ sx={{ marginTop: '3em' }}
+ action={
+ <IconButton
+ aria-label="close"
+ onClick={() => setError(false)}
+ >
+ <CloseIcon />
+ </IconButton>
+ }
+ />
);
}
return null;
diff --git a/libs/components/layout/src/header/LayoutHeader.tsx b/libs/components/layout/src/header/LayoutHeader.tsx
index 9619c97c84..4c17564d9c 100644
--- a/libs/components/layout/src/header/LayoutHeader.tsx
+++ b/libs/components/layout/src/header/LayoutHeader.tsx
@@ -70,9 +70,6 @@ export const LayoutHeader = () => {
<EditorBoardSwitcher />
</StyledContainerForEditorBoardSwitcher>
</StyledHeaderRoot>
- <StyledUnstableTips>
- <StyledUnstableTipsText>{warningTips}</StyledUnstableTipsText>
- </StyledUnstableTips>
</StyledContainerForHeaderRoot>
);
};
diff --git a/libs/components/layout/src/settings-sidebar/Settings/use-setting-flags.ts b/libs/components/layout/src/settings-sidebar/Settings/use-setting-flags.ts
index e0a7fb697c..ff3136b230 100644
--- a/libs/components/layout/src/settings-sidebar/Settings/use-setting-flags.ts
+++ b/libs/components/layout/src/settings-sidebar/Settings/use-setting-flags.ts
@@ -2,8 +2,8 @@ import { useFlag } from '@toeverything/datasource/feature-flags';
export const useSettingFlags = () => {
const booleanFullWidthChecked = useFlag('BooleanFullWidthChecked', false);
- const booleanExportWorkspace = useFlag('BooleanExportWorkspace', false);
- const booleanImportWorkspace = useFlag('BooleanImportWorkspace', false);
+ const booleanExportWorkspace = useFlag('BooleanExportAffineDb', true);
+ const booleanImportWorkspace = useFlag('BooleanImportAffineDb', true);
const booleanExportHtml = useFlag('BooleanExportHtml', false);
const booleanExportPdf = useFlag('BooleanExportPdf', false);
const booleanExportMarkdown = useFlag('BooleanExportMarkdown', false);
diff --git a/libs/components/layout/src/settings-sidebar/Settings/use-settings.ts b/libs/components/layout/src/settings-sidebar/Settings/use-settings.ts
index dfd8918c49..2b32794424 100644
--- a/libs/components/layout/src/settings-sidebar/Settings/use-settings.ts
+++ b/libs/components/layout/src/settings-sidebar/Settings/use-settings.ts
@@ -145,12 +145,19 @@ export const useSettings = (): SettingItem[] => {
type: 'separator',
key: 'separator2',
},
+ {
+ type: 'button',
+ name: t('Clear Workspace'),
+ key: 'Clear Workspace',
+ onClick: () => clearWorkspace(workspaceId),
+ flag: 'booleanClearWorkspace',
+ },
{
type: 'button',
name: t('Import Workspace'),
key: 'Import Workspace',
onClick: () => importWorkspace(workspaceId),
- flag: 'booleanImportWorkspace',
+ flag: 'booleanClearWorkspace',
},
{
type: 'button',
@@ -159,13 +166,6 @@ export const useSettings = (): SettingItem[] => {
onClick: () => exportWorkspace(),
flag: 'booleanExportWorkspace',
},
- {
- type: 'button',
- name: t('Clear Workspace'),
- key: 'Clear Workspace',
- onClick: () => clearWorkspace(workspaceId),
- flag: 'booleanClearWorkspace',
- },
];
return filterSettings(settings, settingFlags);
diff --git a/libs/components/layout/src/settings-sidebar/Settings/util/inspector-workspace.ts b/libs/components/layout/src/settings-sidebar/Settings/util/inspector-workspace.ts
index ee851dc90c..25adfdd669 100644
--- a/libs/components/layout/src/settings-sidebar/Settings/util/inspector-workspace.ts
+++ b/libs/components/layout/src/settings-sidebar/Settings/util/inspector-workspace.ts
@@ -6,8 +6,12 @@ export const importWorkspace = (workspaceId: string) => {
window.client
.inspector()
.load()
- .then(() => {
- window.location.href = `/${workspaceId}/`;
+ .then(status => {
+ if (status) {
+ if (window.confirm('Your currently open data will be lost.')) {
+ window.location.href = `/${workspaceId}/`;
+ }
+ }
});
};
diff --git a/libs/datasource/db-service/src/services/database/index.ts b/libs/datasource/db-service/src/services/database/index.ts
index 3d70345f0f..dbbe23bb9e 100644
--- a/libs/datasource/db-service/src/services/database/index.ts
+++ b/libs/datasource/db-service/src/services/database/index.ts
@@ -39,7 +39,7 @@ async function _getCurrentToken() {
const _enabled = {
demo: [],
- AFFiNE: ['sqlite'],
+ AFFiNE: ['idb'],
} as any;
async function _getBlockDatabase(
diff --git a/libs/datasource/db-service/src/services/workspace/user-config.ts b/libs/datasource/db-service/src/services/workspace/user-config.ts
index 5a52581c21..fbe74ce83d 100644
--- a/libs/datasource/db-service/src/services/workspace/user-config.ts
+++ b/libs/datasource/db-service/src/services/workspace/user-config.ts
@@ -36,7 +36,7 @@ export class UserConfig extends ServiceBaseClass {
}
const db = await this.database.getDatabase(workspace);
- const newPage = await db.get('page');
+ const newPage = await db.get_named_block('start-page');
await this.get_dependency(PageTree).addPage(workspace, newPage.id);
await this.addRecentPage(workspace, userId, newPage.id);
diff --git a/libs/datasource/jwt/src/index.ts b/libs/datasource/jwt/src/index.ts
index e8f3483e23..5c74ae8b99 100644
--- a/libs/datasource/jwt/src/index.ts
+++ b/libs/datasource/jwt/src/index.ts
@@ -357,7 +357,7 @@ export class BlockClient<
* @param name block name
* @returns block instance
*/
- private async get_named_block(
+ public async get_named_block(
name: string,
options?: { workspace?: boolean }
): Promise<BaseBlock<B, C>> {
diff --git a/libs/datasource/jwt/src/yjs/index.ts b/libs/datasource/jwt/src/yjs/index.ts
index 7d0f30e4e3..b94f7009ea 100644
--- a/libs/datasource/jwt/src/yjs/index.ts
+++ b/libs/datasource/jwt/src/yjs/index.ts
@@ -324,53 +324,59 @@ export class YjsAdapter implements AsyncDatabaseAdapter<YjsContentOperation> {
const binary = encodeStateAsUpdate(this._doc);
saveAs(
new Blob([binary]),
- `affine_workspace_${new Date().toDateString()}.apk`
+ `affine_workspace_${new Date().toDateString()}.affine`
);
},
load: async () => {
- const handles = await window.showOpenFilePicker({
- types: [
- {
- description: 'AFFiNE Package',
- accept: {
- // eslint-disable-next-line @typescript-eslint/naming-convention
- 'application/affine': ['.apk'],
+ try {
+ const handles = await window.showOpenFilePicker({
+ types: [
+ {
+ description: 'AFFiNE Package',
+ accept: {
+ // eslint-disable-next-line @typescript-eslint/naming-convention
+ 'application/affine': ['.affine'],
+ },
},
- },
- ],
- });
- const [file] = (await fromEvent(handles)) as File[];
- const binary = await file?.arrayBuffer();
- // await this._provider.idb.clearData();
- const doc = new Doc({ autoLoad: true, shouldLoad: true });
- let updated = 0;
- let isUpdated = false;
- doc.on('update', () => {
- isUpdated = true;
- updated += 1;
- });
- setInterval(() => {
- if (updated > 0) {
- updated -= 1;
+ ],
+ });
+ const [file] = (await fromEvent(handles)) as File[];
+ const binary = await file?.arrayBuffer();
+ // await this._provider.idb.clearData();
+ const doc = new Doc({ autoLoad: true, shouldLoad: true });
+ let updated = 0;
+ let isUpdated = false;
+ doc.on('update', () => {
+ isUpdated = true;
+ updated += 1;
+ });
+ setInterval(() => {
+ if (updated > 0) {
+ updated -= 1;
+ }
+ }, 500);
+
+ const update_check = new Promise<void>(resolve => {
+ const check = async () => {
+ while (!isUpdated || updated > 0) {
+ await sleep();
+ }
+ resolve();
+ };
+ check();
+ });
+ // await new IndexedDBProvider(this._provider.idb.name, doc)
+ // .whenSynced;
+ if (binary) {
+ applyUpdate(doc, new Uint8Array(binary));
+ await update_check;
}
- }, 500);
+ console.log('load success');
- const update_check = new Promise<void>(resolve => {
- const check = async () => {
- while (!isUpdated || updated > 0) {
- await sleep();
- }
- resolve();
- };
- check();
- });
- // await new IndexedDBProvider(this._provider.idb.name, doc)
- // .whenSynced;
- if (binary) {
- applyUpdate(doc, new Uint8Array(binary));
- await update_check;
+ return true;
+ } catch (err) {
+ return false;
}
- console.log('load success');
},
parse: () => this._doc.toJSON(),
// eslint-disable-next-line @typescript-eslint/naming-convention
diff --git a/libs/datasource/state/src/user.ts b/libs/datasource/state/src/user.ts
index 61893471de..953603ef2b 100644
--- a/libs/datasource/state/src/user.ts
+++ b/libs/datasource/state/src/user.ts
@@ -74,41 +74,21 @@ const _useUserAndSpacesForFreeLogin = () => {
if (location.pathname.startsWith('/local')) {
navigate('/local');
} else {
- navigate('/demo');
+ navigate(`/${BRAND_ID}`);
}
setLoading(false);
}
}, []);
useEffect(() => {
- if (localTrigger) {
- setUser({
- photo: '',
- id: BRAND_ID,
- username: BRAND_ID,
- nickname: BRAND_ID,
- email: '',
- });
- } else {
- if (location.pathname.startsWith('/local')) {
- setUser({
- photo: '',
- id: 'local',
- username: 'local',
- nickname: 'local',
- email: '',
- });
- } else {
- setUser({
- photo: '',
- id: 'demo',
- username: 'demo',
- nickname: 'demo',
- email: '',
- });
- }
- }
- }, [localTrigger, location, setLoading, setUser]);
+ setUser({
+ photo: '',
+ id: BRAND_ID,
+ username: BRAND_ID,
+ nickname: BRAND_ID,
+ email: '',
+ });
+ }, [setUser]);
const currentSpaceId: string | undefined = useMemo(() => user?.id, [user]);