File tree Expand file tree Collapse file tree 3 files changed +34
-6
lines changed Expand file tree Collapse file tree 3 files changed +34
-6
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @viamrobotics/svelte-sdk ' : patch
3+ ---
4+
5+ Refetch resourceNames if list is empty and connection established
Original file line number Diff line number Diff line change @@ -35,5 +35,11 @@ export default ts.config(
3535 svelteConfig,
3636 } ,
3737 } ,
38+ } ,
39+ {
40+ rules : {
41+ // Currently has false positives
42+ 'svelte/prefer-svelte-reactivity' : 'off' ,
43+ } ,
3844 }
3945) ;
Original file line number Diff line number Diff line change @@ -76,11 +76,12 @@ export const provideResourceNamesContext = () => {
7676 const clients = useRobotClients ( ) ;
7777
7878 const partIDs = $derived ( Object . keys ( clients . current ) ) ;
79- const options = $derived (
80- partIDs . map ( ( partID ) => {
81- const client = clients . current [ partID ] ;
79+ const options = $derived . by ( ( ) => {
80+ const results = [ ] ;
8281
83- return queryOptions ( {
82+ for ( const partID of partIDs ) {
83+ const client = clients . current [ partID ] ;
84+ const options = queryOptions ( {
8485 enabled : client !== undefined ,
8586 queryKey : [
8687 'viam-svelte-sdk' ,
@@ -100,8 +101,12 @@ export const provideResourceNamesContext = () => {
100101 return resourceNames ;
101102 } ,
102103 } ) ;
103- } )
104- ) ;
104+
105+ results . push ( options ) ;
106+ }
107+
108+ return results ;
109+ } ) ;
105110
106111 const queries = fromStore (
107112 createQueries ( {
@@ -114,6 +119,18 @@ export const provideResourceNamesContext = () => {
114119 } )
115120 ) ;
116121
122+ /**
123+ * ResourceNames are not guaranteed on first fetch,
124+ */
125+ $effect ( ( ) => {
126+ for ( const partID of partIDs ) {
127+ const query = queries . current [ partID ] ;
128+ if ( query ?. isFetched && ! query . isLoading && query . data ?. length === 0 ) {
129+ query . refetch ( ) ;
130+ }
131+ }
132+ } ) ;
133+
117134 /**
118135 * Individually refetch part resource names based on revision
119136 */
You can’t perform that action at this time.
0 commit comments