@@ -12,6 +12,7 @@ import { Config } from '@postgres.ai/shared/types/api/entities/config'
1212import { GetConfig } from '@postgres.ai/shared/types/api/endpoints/getConfig'
1313import { UpdateConfig } from '@postgres.ai/shared/types/api/endpoints/updateConfig'
1414import { TestDbSource } from '@postgres.ai/shared/types/api/endpoints/testDbSource'
15+ import { RefreshInstance } from '@postgres.ai/shared/types/api/endpoints/refreshInstance'
1516import { DestroyClone } from '@postgres.ai/shared/types/api/endpoints/destroyClone'
1617import { ResetClone } from '@postgres.ai/shared/types/api/endpoints/resetClone'
1718import { GetWSToken } from '@postgres.ai/shared/types/api/endpoints/getWSToken'
@@ -30,6 +31,7 @@ const UNSTABLE_CLONE_STATUS_CODES = ['CREATING', 'RESETTING', 'DELETING']
3031export type Api = {
3132 getInstance : GetInstance
3233 getSnapshots : GetSnapshots
34+ refreshInstance ?: RefreshInstance
3335 destroyClone : DestroyClone
3436 resetClone : ResetClone
3537 getWSToken : GetWSToken
@@ -82,6 +84,18 @@ export class MainStore {
8284 }
8385
8486 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 ) => {
8599 this . instance = null
86100 this . isReloadingInstance = true
87101 this . loadInstance ( instanceId )
@@ -120,10 +134,16 @@ export class MainStore {
120134 return ! ! response
121135 }
122136
123- private loadInstance = async ( instanceId : string ) => {
137+ private loadInstance = async (
138+ instanceId : string ,
139+ refresh : boolean = true ,
140+ ) => {
124141 this . instanceError = null
125142 this . isLoadingInstance = true
126143
144+ if ( this . api . refreshInstance && refresh )
145+ await this . api . refreshInstance ( { instanceId : instanceId } )
146+
127147 const { response, error } = await this . api . getInstance ( {
128148 instanceId : instanceId ,
129149 } )
0 commit comments