@@ -26,14 +26,31 @@ export function DbDevtoolsPanel(props: DbDevtoolsPanelProps) {
26
26
string | null
27
27
> ( null )
28
28
29
- const liveQueries = createMemo ( ( ) =>
30
- props . collections . filter ( ( c ) => c . type === `live-query` )
29
+ // Create stable collection IDs that only change when collections are added/removed
30
+ const collectionIds = createMemo ( ( ) => {
31
+ const currentIds = new Set ( props . collections . map ( c => c . id ) )
32
+ return Array . from ( currentIds )
33
+ } )
34
+
35
+ const liveQueryIds = createMemo ( ( ) =>
36
+ collectionIds ( ) . filter ( id => {
37
+ const collection = props . collections . find ( c => c . id === id )
38
+ return collection ?. type === `live-query`
39
+ } )
31
40
)
32
41
33
- const regularCollections = createMemo ( ( ) =>
34
- props . collections . filter ( ( c ) => c . type === `collection` )
42
+ const regularCollectionIds = createMemo ( ( ) =>
43
+ collectionIds ( ) . filter ( id => {
44
+ const collection = props . collections . find ( c => c . id === id )
45
+ return collection ?. type === `collection`
46
+ } )
35
47
)
36
48
49
+ // Helper to get latest metadata for a collection ID
50
+ const getCollectionMetadata = ( id : string ) => {
51
+ return props . collections . find ( c => c . id === id )
52
+ }
53
+
37
54
const allTransactions = createMemo ( ( ) => props . registry . getTransactions ( ) )
38
55
39
56
const handleCollectionSelect = ( id : string ) => {
@@ -187,7 +204,7 @@ export function DbDevtoolsPanel(props: DbDevtoolsPanelProps) {
187
204
< div style = { { flex : `1` , overflow : `auto` } } >
188
205
< Show when = { selectedView ( ) === `collections` } >
189
206
{ /* Live Queries Section */ }
190
- < Show when = { liveQueries ( ) . length > 0 } >
207
+ < Show when = { liveQueryIds ( ) . length > 0 } >
191
208
< div style = { { padding : `16px 0 8px 16px` } } >
192
209
< h3
193
210
style = { {
@@ -199,22 +216,25 @@ export function DbDevtoolsPanel(props: DbDevtoolsPanelProps) {
199
216
"letter-spacing" : `0.5px` ,
200
217
} }
201
218
>
202
- Live Queries ({ liveQueries ( ) . length } )
219
+ Live Queries ({ liveQueryIds ( ) . length } )
203
220
</ h3 >
204
221
</ div >
205
- < For each = { liveQueries ( ) } >
206
- { ( collection ) => (
207
- < CollectionItem
208
- collection = { collection }
209
- isSelected = { selectedCollection ( ) === collection . id }
210
- onClick = { ( ) => handleCollectionSelect ( collection . id ) }
211
- />
212
- ) }
222
+ < For each = { liveQueryIds ( ) } >
223
+ { ( collectionId ) => {
224
+ const collection = getCollectionMetadata ( collectionId )
225
+ return collection ? (
226
+ < CollectionItem
227
+ collection = { collection }
228
+ isSelected = { selectedCollection ( ) === collectionId }
229
+ onClick = { ( ) => handleCollectionSelect ( collectionId ) }
230
+ />
231
+ ) : null
232
+ } }
213
233
</ For >
214
234
</ Show >
215
235
216
236
{ /* Regular Collections Section */ }
217
- < Show when = { regularCollections ( ) . length > 0 } >
237
+ < Show when = { regularCollectionIds ( ) . length > 0 } >
218
238
< div style = { { padding : `16px 0 8px 16px` } } >
219
239
< h3
220
240
style = { {
@@ -226,21 +246,24 @@ export function DbDevtoolsPanel(props: DbDevtoolsPanelProps) {
226
246
"letter-spacing" : `0.5px` ,
227
247
} }
228
248
>
229
- Collections ({ regularCollections ( ) . length } )
249
+ Collections ({ regularCollectionIds ( ) . length } )
230
250
</ h3 >
231
251
</ div >
232
- < For each = { regularCollections ( ) } >
233
- { ( collection ) => (
234
- < CollectionItem
235
- collection = { collection }
236
- isSelected = { selectedCollection ( ) === collection . id }
237
- onClick = { ( ) => handleCollectionSelect ( collection . id ) }
238
- />
239
- ) }
252
+ < For each = { regularCollectionIds ( ) } >
253
+ { ( collectionId ) => {
254
+ const collection = getCollectionMetadata ( collectionId )
255
+ return collection ? (
256
+ < CollectionItem
257
+ collection = { collection }
258
+ isSelected = { selectedCollection ( ) === collectionId }
259
+ onClick = { ( ) => handleCollectionSelect ( collectionId ) }
260
+ />
261
+ ) : null
262
+ } }
240
263
</ For >
241
264
</ Show >
242
265
243
- < Show when = { props . collections . length === 0 } >
266
+ < Show when = { collectionIds ( ) . length === 0 } >
244
267
< div
245
268
style = { {
246
269
padding : `40px 20px` ,
0 commit comments