@@ -2,7 +2,7 @@ import { Disposable, DisposableCollection, GitpodClient, WorkspaceInfo, Workspac
2
2
import { getGitpodService } from "../service/service" ;
3
3
4
4
export class WorkspaceModel implements Disposable , Partial < GitpodClient > {
5
-
5
+
6
6
protected workspaces = new Map < string , WorkspaceInfo > ( ) ;
7
7
protected currentlyFetching = new Set < string > ( ) ;
8
8
protected disposables = new DisposableCollection ( ) ;
@@ -15,7 +15,7 @@ export class WorkspaceModel implements Disposable, Partial<GitpodClient> {
15
15
constructor ( protected setWorkspaces : ( ws : WorkspaceInfo [ ] ) => void ) {
16
16
this . internalRefetch ( ) ;
17
17
}
18
-
18
+
19
19
protected internalRefetch ( ) {
20
20
this . disposables . dispose ( ) ;
21
21
this . disposables = new DisposableCollection ( ) ;
@@ -27,17 +27,17 @@ export class WorkspaceModel implements Disposable, Partial<GitpodClient> {
27
27
} ) ;
28
28
this . disposables . push ( getGitpodService ( ) . registerClient ( this ) ) ;
29
29
}
30
-
30
+
31
31
protected updateMap ( workspaces : WorkspaceInfo [ ] ) {
32
32
for ( const ws of workspaces ) {
33
33
this . workspaces . set ( ws . workspace . id , ws ) ;
34
34
}
35
35
}
36
-
36
+
37
37
dispose ( ) : void {
38
38
this . disposables . dispose ( ) ;
39
39
}
40
-
40
+
41
41
async onInstanceUpdate ( instance : WorkspaceInstance ) {
42
42
if ( this . workspaces ) {
43
43
if ( this . workspaces . has ( instance . workspaceId ) ) {
@@ -58,7 +58,13 @@ export class WorkspaceModel implements Disposable, Partial<GitpodClient> {
58
58
}
59
59
}
60
60
}
61
-
61
+
62
+ async deleteWorkspace ( id : string ) : Promise < void > {
63
+ await getGitpodService ( ) . server . deleteWorkspace ( id ) ;
64
+ this . workspaces . delete ( id ) ;
65
+ this . notifyWorkpaces ( ) ;
66
+ }
67
+
62
68
protected internalActive = true ;
63
69
get active ( ) {
64
70
return this . internalActive ;
0 commit comments