mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
feat: bare client for non-auth apis
This commit is contained in:
@@ -13,7 +13,7 @@ import type {
|
||||
LoadWorkspaceHandler,
|
||||
CreateEditorHandler,
|
||||
} from './context';
|
||||
import { downloadWorkspace, getToken } from '@pathfinder/data-services';
|
||||
import { downloadWorkspace, token } from '@pathfinder/data-services';
|
||||
import { WebsocketProvider } from './y-websocket';
|
||||
|
||||
const getEditorParams = (workspaceId: string) => {
|
||||
@@ -55,11 +55,9 @@ const DynamicBlocksuite = ({
|
||||
providers: [IndexedDBDocProvider],
|
||||
}).register(BlockSchema);
|
||||
|
||||
const refreshToken = getToken()?.refreshToken;
|
||||
|
||||
if (
|
||||
websocket &&
|
||||
refreshToken &&
|
||||
token.refresh &&
|
||||
location.search.includes('sync=websocket')
|
||||
) {
|
||||
// FIXME: if add websocket provider, the first page will be blank
|
||||
@@ -71,7 +69,7 @@ const DynamicBlocksuite = ({
|
||||
workspace.doc,
|
||||
{
|
||||
params: {
|
||||
token: refreshToken,
|
||||
token: token.refresh,
|
||||
},
|
||||
awareness: workspace.meta.awareness.awareness,
|
||||
}
|
||||
|
||||
@@ -2,11 +2,9 @@ import { useMemo, useState, useEffect, useCallback, useRef } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import {
|
||||
authorizationEvent,
|
||||
token,
|
||||
AccessTokenMessage,
|
||||
getWorkspaces,
|
||||
WorkspaceType,
|
||||
getWorkspaceDetail,
|
||||
} from '@pathfinder/data-services';
|
||||
import { AppState, AppStateContext } from './context';
|
||||
import type {
|
||||
@@ -171,10 +169,10 @@ export const AppStateProvider = ({ children }: { children?: ReactNode }) => {
|
||||
synced: true,
|
||||
}));
|
||||
};
|
||||
authorizationEvent.onChange(callback);
|
||||
token.onChange(callback);
|
||||
|
||||
return () => {
|
||||
authorizationEvent.removeCallback(callback);
|
||||
token.offChange(callback);
|
||||
};
|
||||
}, [loadWorkspaceHandler]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user