@@ -12,6 +12,7 @@ import { Config } from '@postgres.ai/shared/types/api/entities/config'
12
12
import { GetConfig } from '@postgres.ai/shared/types/api/endpoints/getConfig'
13
13
import { UpdateConfig } from '@postgres.ai/shared/types/api/endpoints/updateConfig'
14
14
import { TestDbSource } from '@postgres.ai/shared/types/api/endpoints/testDbSource'
15
+ import { RefreshInstance } from '@postgres.ai/shared/types/api/endpoints/refreshInstance'
15
16
import { DestroyClone } from '@postgres.ai/shared/types/api/endpoints/destroyClone'
16
17
import { ResetClone } from '@postgres.ai/shared/types/api/endpoints/resetClone'
17
18
import { GetWSToken } from '@postgres.ai/shared/types/api/endpoints/getWSToken'
@@ -30,6 +31,7 @@ const UNSTABLE_CLONE_STATUS_CODES = ['CREATING', 'RESETTING', 'DELETING']
30
31
export type Api = {
31
32
getInstance : GetInstance
32
33
getSnapshots : GetSnapshots
34
+ refreshInstance ?: RefreshInstance
33
35
destroyClone : DestroyClone
34
36
resetClone : ResetClone
35
37
getWSToken : GetWSToken
@@ -82,6 +84,18 @@ export class MainStore {
82
84
}
83
85
84
86
load = ( instanceId : string ) => {
87
+ this . instance = null
88
+ this . isReloadingInstance = true
89
+ this . loadInstance ( instanceId , false )
90
+ this . loadInstanceRetrieval ( instanceId ) . then ( ( ) => {
91
+ if ( this . instanceRetrieval ) {
92
+ this . getConfig ( )
93
+ }
94
+ } )
95
+ this . snapshots . load ( instanceId )
96
+ }
97
+
98
+ reload = ( instanceId : string ) => {
85
99
this . instance = null
86
100
this . isReloadingInstance = true
87
101
this . loadInstance ( instanceId )
@@ -120,10 +134,16 @@ export class MainStore {
120
134
return ! ! response
121
135
}
122
136
123
- private loadInstance = async ( instanceId : string ) => {
137
+ private loadInstance = async (
138
+ instanceId : string ,
139
+ refresh : boolean = true ,
140
+ ) => {
124
141
this . instanceError = null
125
142
this . isLoadingInstance = true
126
143
144
+ if ( this . api . refreshInstance && refresh )
145
+ await this . api . refreshInstance ( { instanceId : instanceId } )
146
+
127
147
const { response, error } = await this . api . getInstance ( {
128
148
instanceId : instanceId ,
129
149
} )
0 commit comments