@@ -253,9 +253,28 @@ export function useCatalogOperations(client: v1.DockerDesktopClient) {
253
253
return { success : true , newRegistry } ;
254
254
} catch ( error ) {
255
255
client . desktopUI . toast . error ( 'Failed to register catalog item: ' + error ) ;
256
+ // Treat YAML file write failures as fatal, no rollback
256
257
throw error ;
257
258
}
258
259
} ,
260
+ onMutate : async ( { item } ) => {
261
+ // Optimistically update the registry data
262
+ const currentRegistry = queryClient . getQueryData ( [ 'registry' ] ) as { [ key : string ] : { ref : string ; config ?: any } } || { } ;
263
+ const newRegistry : { [ key : string ] : { ref : string ; config ?: any } } = {
264
+ ...currentRegistry ,
265
+ [ item . name ] : { ref : item . ref }
266
+ } ;
267
+
268
+ // If there's config, add it
269
+ if ( item . config && config && config [ item . name ] ) {
270
+ newRegistry [ item . name ] = {
271
+ ...newRegistry [ item . name ] ,
272
+ config : config [ item . name ]
273
+ } ;
274
+ }
275
+
276
+ queryClient . setQueryData ( [ 'registry' ] , newRegistry ) ;
277
+ } ,
259
278
onSuccess : async ( data ) => {
260
279
// Update the registry data after successful registration
261
280
queryClient . setQueryData ( [ 'registry' ] , data . newRegistry ) ;
@@ -285,9 +304,21 @@ export function useCatalogOperations(client: v1.DockerDesktopClient) {
285
304
return { success : true , newRegistry : currentRegistry } ;
286
305
} catch ( error ) {
287
306
client . desktopUI . toast . error ( 'Failed to unregister catalog item: ' + error ) ;
307
+ // Treat YAML file write failures as fatal, no rollback
288
308
throw error ;
289
309
}
290
310
} ,
311
+ onMutate : async ( item ) => {
312
+ // Optimistically update the registry data
313
+ const currentRegistry = { ...( queryClient . getQueryData ( [ 'registry' ] ) as { [ key : string ] : { ref : string ; config ?: any } } || { } ) } ;
314
+
315
+ // Remove the item
316
+ if ( currentRegistry [ item . name ] ) {
317
+ delete currentRegistry [ item . name ] ;
318
+ }
319
+
320
+ queryClient . setQueryData ( [ 'registry' ] , currentRegistry ) ;
321
+ } ,
291
322
onSuccess : async ( data ) => {
292
323
// Update the registry data after successful unregistration
293
324
queryClient . setQueryData ( [ 'registry' ] , data . newRegistry ) ;
0 commit comments