@@ -102,15 +102,22 @@ cls.ResourceManagerService = function(view, network_logger)
102102 var windowID_index = { } ;
103103 ctx . windowList . forEach ( function ( w , i ) { windowID_index [ w . id ] = i ; } ) ;
104104
105+ var nullDocumentID = false ;
105106 var documentID_index = { } ;
106- // filter the documentId that belong in the windowIdList
107+ // filter the documentId that belong in the windowIdList,
108+ // set nullDocumentID flag,
109+ // augment the document objects,
110+ // set the default collapsed flags
107111 ctx . documentList = this . _documentList
108112 . filter ( function ( d , i , a )
109113 {
110114 var inContext = windowID_index . hasOwnProperty ( d . windowID ) ;
111115
112116 if ( inContext )
113117 {
118+ if ( ! nullDocumentID && ! d . documentID )
119+ nullDocumentID = true ;
120+
114121 if ( d . resourceID != null )
115122 ctx . documentResourceHash [ d . resourceID ] = d . documentID ;
116123
@@ -136,12 +143,18 @@ cls.ResourceManagerService = function(view, network_logger)
136143 return inContext ;
137144 } , this ) ;
138145
139- // assign top resource to the right document
140- // add group to each resource
146+ var unknownDocumentID = false ;
147+
148+ // set unknownDocumentID flag,
149+ // assign top resource to the right document,
150+ // add group to each resource,
141151 // sameOrigin flag to each resource
142152 ctx . resourceList
143153 . forEach ( function ( r )
144154 {
155+ if ( ! unknownDocumentID && ! documentID_index . hasOwnProperty ( r . document_id ) )
156+ unknownDocumentID = true ;
157+
145158 // check if this is the top resource of a document
146159 var documentID = ctx . documentResourceHash [ r . resource_id ] ;
147160 if ( documentID != null && documentID != r . document_id )
@@ -169,21 +182,7 @@ cls.ResourceManagerService = function(view, network_logger)
169182 // an empty documentList
170183 // or a resource pointing to an unknown document
171184 // or a document does not have a documentID yet
172- if (
173- ctx . documentList . length == 0
174- ||
175- ctx . resourceList
176- . some ( function ( v )
177- {
178- return v . document_id && ! documentID_index [ v . document_id ] ;
179- } , this )
180- ||
181- ctx . documentList
182- . some ( function ( v )
183- {
184- return v . documentID == null ;
185- } )
186- )
185+ if ( ! ctx . documentList . length || unknownDocumentID || nullDocumentID )
187186 this . _listDocuments ( ) ;
188187
189188 ctx . selectedResourceUID = this . _selectedResourceUID ;
@@ -312,7 +311,6 @@ cls.ResourceManagerService = function(view, network_logger)
312311 this . _selectedResourceUID = null ;
313312
314313 this . _documentList = [ ] ;
315- this . _documentURLHash = { } ;
316314 this . _collapsedHash = { } ;
317315 this . _documentResources = { } ;
318316
0 commit comments