fix: disable sqlite provider (#2888)

Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
Peng Xiao
2023-06-28 15:01:15 +08:00
committed by GitHub
parent fd0aa4a2ee
commit 79b3b1dabc
14 changed files with 145 additions and 119 deletions
@@ -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 now
@@ -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 = () => {
<Button
type="light"
shape="circle"
disabled={!environment.isDesktop || !id}
disabled={!environment.isDesktop || !id || !config.enableSQLiteProvider}
data-testid="export-affine-backup"
onClick={async () => {
if (id) {
@@ -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);
});