Merge pull request #886 from toeverything/feat/sync-status

fix: logout will jump to 404 error
This commit is contained in:
DarkSky
2023-02-08 23:22:10 +08:00
committed by GitHub
7 changed files with 72 additions and 52 deletions

View File

@@ -430,7 +430,7 @@ export class AffineProvider extends BaseProvider {
token.clear();
this._channel?.disconnect();
this._wsMap.forEach(ws => ws.disconnect());
this._workspaces.clear();
this._workspaces.clear(false);
storage.removeItem('token');
}

View File

@@ -8,8 +8,8 @@ export interface WorkspaceUnitCollectionScope {
get: (workspaceId: string) => WorkspaceUnit | undefined;
list: () => WorkspaceUnit[];
add: (workspace: WorkspaceUnit | WorkspaceUnit[]) => void;
remove: (workspaceId: string | string[]) => boolean;
clear: () => void;
remove: (workspaceId: string | string[], isUpdate?: boolean) => boolean;
clear: (isUpdate?: boolean) => void;
update: (
workspaceId: string,
workspaceUnit: UpdateWorkspaceUnitParams
@@ -85,7 +85,7 @@ export class WorkspaceUnitCollection {
]);
};
const remove = (workspaceId: string | string[]) => {
const remove = (workspaceId: string | string[], isUpdate = true) => {
const workspaceIds = Array.isArray(workspaceId)
? workspaceId
: [workspaceId];
@@ -111,18 +111,19 @@ export class WorkspaceUnitCollection {
if (!workspaceUnits.length) {
return false;
}
this._events.emit('change', [
{
deleted: workspaceUnits,
} as WorkspaceUnitCollectionChangeEvent,
]);
if (isUpdate) {
this._events.emit('change', [
{
deleted: workspaceUnits,
} as WorkspaceUnitCollectionChangeEvent,
]);
}
return true;
};
const clear = () => {
remove(Array.from(scopedWorkspaceIds));
const clear = (isUpdate = true) => {
remove(Array.from(scopedWorkspaceIds), isUpdate);
};
const update = (workspaceId: string, meta: UpdateWorkspaceUnitParams) => {