mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-06 00:41:39 +08:00
fix: authorization token refresh
This commit is contained in:
@@ -92,7 +92,7 @@ const DynamicBlocksuite = ({
|
|||||||
(indexDBProvider as IndexedDBDocProvider)?.on('synced', async () => {
|
(indexDBProvider as IndexedDBDocProvider)?.on('synced', async () => {
|
||||||
const updates = await downloadWorkspace({ workspaceId });
|
const updates = await downloadWorkspace({ workspaceId });
|
||||||
|
|
||||||
if (updates.byteLength) {
|
if (updates && updates.byteLength) {
|
||||||
Workspace.Y.applyUpdate(workspace.doc, new Uint8Array(updates));
|
Workspace.Y.applyUpdate(workspace.doc, new Uint8Array(updates));
|
||||||
// if after update, the space:meta is empty, then we need to get map with doc
|
// if after update, the space:meta is empty, then we need to get map with doc
|
||||||
workspace.doc.getMap('space:meta');
|
workspace.doc.getMap('space:meta');
|
||||||
|
|||||||
@@ -94,6 +94,10 @@ export async function setAuthorization(config: AxiosRequestConfig<unknown>) {
|
|||||||
}
|
}
|
||||||
if (isAccessTokenExpired(token.accessToken)) {
|
if (isAccessTokenExpired(token.accessToken)) {
|
||||||
await refreshToken();
|
await refreshToken();
|
||||||
|
token = getToken();
|
||||||
|
}
|
||||||
|
if (!token) {
|
||||||
|
throw new Error('No authorization token.');
|
||||||
}
|
}
|
||||||
if (!config.headers) {
|
if (!config.headers) {
|
||||||
config.headers = {};
|
config.headers = {};
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ export async function downloadWorkspace(
|
|||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
});
|
});
|
||||||
|
|
||||||
return data.data;
|
return data?.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uploadBlob(params: { blob: Blob }): Promise<string> {
|
export async function uploadBlob(params: { blob: Blob }): Promise<string> {
|
||||||
|
|||||||
Reference in New Issue
Block a user