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: syncing images (#1501)
Himself65eb0d6ee08ed0
diff --git a/apps/web/src/plugins/affine/index.tsx b/apps/web/src/plugins/affine/index.tsxindex ba599a6023..8cab219324 100644--- a/apps/web/src/plugins/affine/index.tsx+++ b/apps/web/src/plugins/affine/index.tsx@@ -14,7 +14,7 @@ import {LoadPriority,RemWorkspaceFlavour,} from '../../shared';-import { apis } from '../../shared/apis';+import { apis, clientAuth } from '../../shared/apis';import { createEmptyBlockSuiteWorkspace } from '../../utils';import { WorkspacePlugin } from '..';import { fetcher, QueryKey } from './fetcher';@@ -68,6 +68,27 @@ export const AffinePlugin: WorkspacePlugin<RemWorkspaceFlavour.AFFINE> = {blockSuiteWorkspace.doc);const { id } = await apis.createWorkspace(new Blob([binary.buffer]));+ // fixme: syncing images+ const newWorkspaceId = id;++ await new Promise(resolve => setTimeout(resolve, 1000));+ const blobs = await blockSuiteWorkspace.blobs;+ if (blobs) {+ const ids = await blobs.blobs;+ for (const id of ids) {+ const url = await blobs.get(id);+ if (url) {+ const blob = await fetch(url).then(res => res.blob());+ await clientAuth.put(`api/workspace/${newWorkspaceId}/blob`, {+ body: blob,+ headers: {+ 'Content-Type': blob.type,+ },+ });+ }+ }+ }+await mutate(matcher => matcher === QueryKey.getWorkspaces);// refresh the local storageawait AffinePlugin.CRUD.list();diff --git a/apps/web/src/shared/apis.ts b/apps/web/src/shared/apis.tsindex 00b9a9283c..313740c7c7 100644--- a/apps/web/src/shared/apis.ts+++ b/apps/web/src/shared/apis.ts@@ -22,5 +22,5 @@ if (typeof window === 'undefined') {const bareAuth = createBareClient(prefixUrl);const googleAuth = new GoogleAuth(bareAuth);-const clientAuth = createAuthClient(bareAuth, googleAuth);+export const clientAuth = createAuthClient(bareAuth, googleAuth);export const apis = getApis(bareAuth, clientAuth, googleAuth);