@@ -59,8 +59,6 @@ export default class DBFolderPlugin extends Plugin {
5959
6060 databaseFileModes : Record < string , string > = { } ;
6161
62- viewMap : Map < string , DatabaseView > = new Map ( ) ;
63-
6462 _loaded = false ;
6563
6664 stateManagers : Map < TFile , StateManager > = new Map ( ) ;
@@ -189,8 +187,8 @@ export default class DBFolderPlugin extends Plugin {
189187 return ;
190188 }
191189
192- if ( ! this . viewMap . has ( view . id ) ) {
193- this . viewMap . set ( view . id , view ) ;
190+ if ( ! reg . viewMap . has ( view . id ) ) {
191+ reg . viewMap . set ( view . id , view ) ;
194192 }
195193
196194 const file = view . file ;
@@ -408,27 +406,30 @@ export default class DBFolderPlugin extends Plugin {
408406 */
409407 this . registerEvent (
410408 app . metadataCache . on ( "dataview:index-ready" , async ( ) => {
411- // Refresh all database views
412- this . viewMap . forEach ( async ( view ) => {
413- await view . reloadDatabase ( ) ;
414- } ) ;
409+ for ( const [ win , { viewMap } ] of Array . from ( this . windowRegistry . entries ( ) ) ) {
410+ // Refresh all database views
411+ for ( const view of viewMap . values ( ) ) {
412+ await view . reloadDatabase ( ) ;
413+ }
414+ }
415415 /**
416416 * Once the index is ready, we can start listening for metadata changes.
417417 */
418418 if ( this . settings . global_settings . enable_auto_update ) {
419419 this . registerEvent ( app . metadataCache . on ( "dataview:metadata-change" ,
420420 ( type , file , oldPath ?) => {
421421 const activeView = app . workspace . getActiveViewOfType ( DatabaseView ) ;
422- // Iterate through all the views and reload the database if the file is the same
423- this . viewMap . forEach ( async ( view ) => {
424- const isActive = activeView && ( view . file . path === activeView . file . path ) ;
425- view . handleExternalMetadataChange ( type , file , isActive , oldPath ) ;
422+ Array . from ( this . windowRegistry . entries ( ) ) . forEach ( async ( [ , { viewMap } ] ) => {
423+ // Iterate through all the views and reload the database if the file is the same
424+ viewMap . forEach ( async ( view ) => {
425+ const isActive = activeView && ( view . file . path === activeView ?. file . path ) ;
426+ view . handleExternalMetadataChange ( type , file , isActive , oldPath ) ;
427+ } ) ;
426428 } ) ;
427429 } )
428430 ) ;
429431 }
430- } )
431- ) ;
432+ } ) ) ;
432433
433434 /**
434435 * Check when the active view focus changes and update bar status
0 commit comments