mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-29 21:12:59 +03:00
feat: change the order of load workspaces
This commit is contained in:
parent
b4571539ac
commit
104693916f
@ -46,6 +46,10 @@ export class DataCenter {
|
|||||||
dc.registerProvider(new LocalProvider(getInitParams()));
|
dc.registerProvider(new LocalProvider(getInitParams()));
|
||||||
dc.registerProvider(new AffineProvider(getInitParams()));
|
dc.registerProvider(new AffineProvider(getInitParams()));
|
||||||
|
|
||||||
|
for (const provider of dc.providerMap.values()) {
|
||||||
|
await provider.loadWorkspaces();
|
||||||
|
}
|
||||||
|
|
||||||
return dc;
|
return dc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,8 +185,14 @@ export class DataCenter {
|
|||||||
* @param {Function} callback callback function
|
* @param {Function} callback callback function
|
||||||
*/
|
*/
|
||||||
public async onWorkspacesChange(
|
public async onWorkspacesChange(
|
||||||
callback: (workspaces: WorkspaceUnitCollectionChangeEvent) => void
|
callback: (workspaces: WorkspaceUnitCollectionChangeEvent) => void,
|
||||||
|
{ immediate = true }: { immediate?: boolean }
|
||||||
) {
|
) {
|
||||||
|
if (immediate) {
|
||||||
|
callback({
|
||||||
|
added: this._workspaceUnitCollection.workspaces,
|
||||||
|
});
|
||||||
|
}
|
||||||
this._workspaceUnitCollection.on('change', callback);
|
this._workspaceUnitCollection.on('change', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import { BaseProvider } from '../base.js';
|
|||||||
import type {
|
import type {
|
||||||
ProviderConstructorParams,
|
ProviderConstructorParams,
|
||||||
CreateWorkspaceInfoParams,
|
CreateWorkspaceInfoParams,
|
||||||
UpdateWorkspaceMetaParams,
|
|
||||||
WorkspaceMeta0,
|
WorkspaceMeta0,
|
||||||
} from '../base';
|
} from '../base';
|
||||||
import type { User } from '../../types';
|
import type { User } from '../../types';
|
||||||
@ -34,11 +33,6 @@ export class AffineProvider extends BaseProvider {
|
|||||||
constructor({ apis, ...params }: AffineProviderConstructorParams) {
|
constructor({ apis, ...params }: AffineProviderConstructorParams) {
|
||||||
super(params);
|
super(params);
|
||||||
this._apis = apis || getApis();
|
this._apis = apis || getApis();
|
||||||
this.init().then(() => {
|
|
||||||
if (this._apis.token.isLogin) {
|
|
||||||
this.loadWorkspaces();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override async init() {
|
override async init() {
|
||||||
|
@ -19,7 +19,6 @@ export class LocalProvider extends BaseProvider {
|
|||||||
|
|
||||||
constructor(params: ProviderConstructorParams) {
|
constructor(params: ProviderConstructorParams) {
|
||||||
super(params);
|
super(params);
|
||||||
this.loadWorkspaces();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _storeWorkspaces(workspaces: WorkspaceMeta0[]) {
|
private _storeWorkspaces(workspaces: WorkspaceMeta0[]) {
|
||||||
|
@ -18,7 +18,7 @@ export interface WorkspaceUnitCollectionScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface WorkspaceUnitCollectionChangeEvent {
|
export interface WorkspaceUnitCollectionChangeEvent {
|
||||||
added?: WorkspaceUnit;
|
added?: WorkspaceUnit[];
|
||||||
deleted?: WorkspaceUnit;
|
deleted?: WorkspaceUnit;
|
||||||
updated?: WorkspaceUnit;
|
updated?: WorkspaceUnit;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ export class WorkspaceUnitCollection {
|
|||||||
|
|
||||||
this._events.emit('change', [
|
this._events.emit('change', [
|
||||||
{
|
{
|
||||||
added: workspaceUnit,
|
added: [workspaceUnit],
|
||||||
} as WorkspaceUnitCollectionChangeEvent,
|
} as WorkspaceUnitCollectionChangeEvent,
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user