mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 11:59:51 +08:00
1.adjust code style.
This commit is contained in:
@@ -4,7 +4,7 @@ import { CloseIcon } from '@toeverything/components/common';
|
|||||||
import { IconButton, MuiSnackbar, styled } from '@toeverything/components/ui';
|
import { IconButton, MuiSnackbar, styled } from '@toeverything/components/ui';
|
||||||
import { services } from '@toeverything/datasource/db-service';
|
import { services } from '@toeverything/datasource/db-service';
|
||||||
import { useLocalTrigger } from '@toeverything/datasource/state';
|
import { useLocalTrigger } from '@toeverything/datasource/state';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
const cleanupWorkspace = (workspace: string) =>
|
const cleanupWorkspace = (workspace: string) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
const req = indexedDB.deleteDatabase(workspace);
|
const req = indexedDB.deleteDatabase(workspace);
|
||||||
@@ -75,25 +75,39 @@ export const FileSystem = () => {
|
|||||||
setError(true);
|
setError(true);
|
||||||
setTimeout(() => setError(false), 3000);
|
setTimeout(() => setError(false), 3000);
|
||||||
}, []);
|
}, []);
|
||||||
const { t } = useTranslation();
|
|
||||||
const apiSupported = useMemo(() => fsApiSupported(), []);
|
const apiSupported = useMemo(() => fsApiSupported(), []);
|
||||||
|
|
||||||
if (apiSupported && !selected) {
|
if (apiSupported && !selected) {
|
||||||
return (
|
return (
|
||||||
<MuiSnackbar
|
<>
|
||||||
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
|
<MuiSnackbar
|
||||||
open={error}
|
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
|
||||||
message="Request File Permission failed, please check if you have permission"
|
open={error}
|
||||||
sx={{ marginTop: '3em' }}
|
message="Request File Permission failed, please check if you have permission"
|
||||||
action={
|
sx={{ marginTop: '3em' }}
|
||||||
<IconButton
|
action={
|
||||||
aria-label="close"
|
<IconButton
|
||||||
onClick={() => setError(false)}
|
aria-label="close"
|
||||||
>
|
onClick={() => setError(false)}
|
||||||
<CloseIcon />
|
>
|
||||||
</IconButton>
|
<CloseIcon />
|
||||||
}
|
</IconButton>
|
||||||
/>
|
}
|
||||||
|
/>
|
||||||
|
<StyledFileSystem
|
||||||
|
onClick={async () => {
|
||||||
|
try {
|
||||||
|
await requestPermission('AFFiNE');
|
||||||
|
onSelected();
|
||||||
|
} catch (e) {
|
||||||
|
onError();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Sync to Disk
|
||||||
|
</StyledFileSystem>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { EditorBoardSwitcher } from './EditorBoardSwitcher';
|
import { EditorBoardSwitcher } from './EditorBoardSwitcher';
|
||||||
import { FileSystem, fsApiSupported } from './FileSystem';
|
import { fsApiSupported } from './FileSystem';
|
||||||
import { CurrentPageTitle } from './Title';
|
import { CurrentPageTitle } from './Title';
|
||||||
|
|
||||||
export const LayoutHeader = () => {
|
export const LayoutHeader = () => {
|
||||||
@@ -44,7 +44,6 @@ export const LayoutHeader = () => {
|
|||||||
</FlexContainer>
|
</FlexContainer>
|
||||||
<FlexContainer>
|
<FlexContainer>
|
||||||
<StyledHelper>
|
<StyledHelper>
|
||||||
<FileSystem />
|
|
||||||
<StyledShare disabled={true}>{t('Share')}</StyledShare>
|
<StyledShare disabled={true}>{t('Share')}</StyledShare>
|
||||||
<div style={{ margin: '0px 12px' }}>
|
<div style={{ margin: '0px 12px' }}>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ function PageSettingPortal() {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { user } = useUserAndSpaces();
|
const { user } = useUserAndSpaces();
|
||||||
const BooleanFullWidthChecked = useFlag('BooleanFullWidthChecked', false);
|
const BooleanFullWidthChecked = useFlag('BooleanFullWidthChecked', false);
|
||||||
const BooleanExportWorkspace = useFlag('BooleanExportWorkspace', false);
|
|
||||||
const BooleanImportWorkspace = useFlag('BooleanImportWorkspace', false);
|
|
||||||
const BooleanExportHtml = useFlag('BooleanExportHtml', false);
|
const BooleanExportHtml = useFlag('BooleanExportHtml', false);
|
||||||
const BooleanExportPdf = useFlag('BooleanExportPdf', false);
|
const BooleanExportPdf = useFlag('BooleanExportPdf', false);
|
||||||
const BooleanExportMarkdown = useFlag('BooleanExportMarkdown', false);
|
const BooleanExportMarkdown = useFlag('BooleanExportMarkdown', false);
|
||||||
@@ -217,18 +215,14 @@ function PageSettingPortal() {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Divider />
|
<Divider />
|
||||||
{BooleanImportWorkspace && (
|
<ListButton
|
||||||
<ListButton
|
content="Import Workspace"
|
||||||
content="Import Workspace"
|
onClick={handleImportWorkspace}
|
||||||
onClick={handleImportWorkspace}
|
/>
|
||||||
/>
|
<ListButton
|
||||||
)}
|
content="Export Workspace"
|
||||||
{BooleanExportWorkspace && (
|
onClick={handleExportWorkspace}
|
||||||
<ListButton
|
/>
|
||||||
content="Export Workspace"
|
|
||||||
onClick={handleExportWorkspace}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<p className="textDescription">
|
<p className="textDescription">
|
||||||
Last edited by {user && user.nickname}
|
Last edited by {user && user.nickname}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import { useFlag } from '@toeverything/datasource/feature-flags';
|
|||||||
|
|
||||||
export const useSettingFlags = () => {
|
export const useSettingFlags = () => {
|
||||||
const booleanFullWidthChecked = useFlag('BooleanFullWidthChecked', false);
|
const booleanFullWidthChecked = useFlag('BooleanFullWidthChecked', false);
|
||||||
const booleanExportWorkspace = useFlag('BooleanExportAffineDb', true);
|
|
||||||
const booleanImportWorkspace = useFlag('BooleanImportAffineDb', true);
|
|
||||||
const booleanExportHtml = useFlag('BooleanExportHtml', false);
|
const booleanExportHtml = useFlag('BooleanExportHtml', false);
|
||||||
const booleanExportPdf = useFlag('BooleanExportPdf', false);
|
const booleanExportPdf = useFlag('BooleanExportPdf', false);
|
||||||
const booleanExportMarkdown = useFlag('BooleanExportMarkdown', false);
|
const booleanExportMarkdown = useFlag('BooleanExportMarkdown', false);
|
||||||
@@ -11,8 +9,6 @@ export const useSettingFlags = () => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
booleanFullWidthChecked,
|
booleanFullWidthChecked,
|
||||||
booleanExportWorkspace,
|
|
||||||
booleanImportWorkspace,
|
|
||||||
booleanExportHtml,
|
booleanExportHtml,
|
||||||
booleanExportPdf,
|
booleanExportPdf,
|
||||||
booleanExportMarkdown,
|
booleanExportMarkdown,
|
||||||
|
|||||||
@@ -156,15 +156,13 @@ export const useSettings = (): SettingItem[] => {
|
|||||||
type: 'button',
|
type: 'button',
|
||||||
name: t('Import Workspace'),
|
name: t('Import Workspace'),
|
||||||
key: 'Import Workspace',
|
key: 'Import Workspace',
|
||||||
onClick: () => importWorkspace(workspaceId),
|
onClick: () => importWorkspace(),
|
||||||
flag: 'booleanClearWorkspace',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
name: t('Export Workspace'),
|
name: t('Export Workspace'),
|
||||||
key: 'Export Workspace',
|
key: 'Export Workspace',
|
||||||
onClick: () => exportWorkspace(),
|
onClick: () => exportWorkspace(),
|
||||||
flag: 'booleanExportWorkspace',
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
/**
|
/**
|
||||||
* @deprecated debugging method, deprecated
|
* @deprecated debugging method, deprecated
|
||||||
*/
|
*/
|
||||||
export const importWorkspace = (workspaceId: string) => {
|
export const importWorkspace = async () => {
|
||||||
//@ts-ignore
|
if (window.confirm('Your currently open data will be lost.')) {
|
||||||
window.client
|
//@ts-ignore
|
||||||
.inspector()
|
const status = await window.client.inspector().load();
|
||||||
.load()
|
|
||||||
.then(status => {
|
console.log(status);
|
||||||
if (status) {
|
|
||||||
if (window.confirm('Your currently open data will be lost.')) {
|
if (status) {
|
||||||
window.location.href = `/${workspaceId}/`;
|
window.location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export class UserConfig extends ServiceBaseClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const db = await this.database.getDatabase(workspace);
|
const db = await this.database.getDatabase(workspace);
|
||||||
const newPage = await db.get_named_block('start-page');
|
const newPage = await db.getNamedBlock('start-page');
|
||||||
|
|
||||||
await this.get_dependency(PageTree).addPage(workspace, newPage.id);
|
await this.get_dependency(PageTree).addPage(workspace, newPage.id);
|
||||||
await this.addRecentPage(workspace, userId, newPage.id);
|
await this.addRecentPage(workspace, userId, newPage.id);
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ export class BlockClient<
|
|||||||
* @param name block name
|
* @param name block name
|
||||||
* @returns block instance
|
* @returns block instance
|
||||||
*/
|
*/
|
||||||
public async get_named_block(
|
public async getNamedBlock(
|
||||||
name: string,
|
name: string,
|
||||||
options?: { workspace?: boolean }
|
options?: { workspace?: boolean }
|
||||||
): Promise<BaseBlock<B, C>> {
|
): Promise<BaseBlock<B, C>> {
|
||||||
@@ -376,7 +376,7 @@ export class BlockClient<
|
|||||||
*/
|
*/
|
||||||
public async getWorkspace() {
|
public async getWorkspace() {
|
||||||
if (!this._root.node) {
|
if (!this._root.node) {
|
||||||
this._root.node = await this.get_named_block(this._workspace, {
|
this._root.node = await this.getNamedBlock(this._workspace, {
|
||||||
workspace: true,
|
workspace: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,7 +371,6 @@ export class YjsAdapter implements AsyncDatabaseAdapter<YjsContentOperation> {
|
|||||||
applyUpdate(doc, new Uint8Array(binary));
|
applyUpdate(doc, new Uint8Array(binary));
|
||||||
await update_check;
|
await update_check;
|
||||||
}
|
}
|
||||||
console.log('load success');
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user