@@ -782,7 +782,7 @@ export class Model {
782782 } ;
783783
784784 types . forEach ( ( type ) => {
785- if ( this . loadedTypes [ type ] != null ) {
785+ if ( this . loadedTypes [ type ] && Object . getOwnPropertyNames ( this . loadedTypes [ type ] ) . length !== 0 ) {
786786 for ( let oid in this . loadedTypes [ type ] ) {
787787 callback ( this . loadedTypes [ type ] [ oid ] ) ;
788788 }
@@ -806,32 +806,30 @@ export class Model {
806806 serializerOid : serializer . oid
807807 } ) ;
808808 this . bimServerApi . getJson ( url , null , ( data ) => {
809- if ( this . loadedTypes [ type ] == null ) {
810- this . loadedTypes [ type ] = { } ;
811- }
812- data . objects . some ( ( object ) => {
813- if ( this . objects [ object . _i ] != null ) {
809+ data . objects . forEach ( ( object ) => {
810+ if ( this . objects [ object . _i ] ) {
814811 // Hmm we are doing a query on type, but some objects have already loaded, let's use those instead
815812 const wrapper = this . objects [ object . _i ] ;
816813 if ( wrapper . object . _s == 1 ) {
817- if ( wrapper . isA ( type ) ) {
818- this . loadedTypes [ type ] [ object . _i ] = wrapper ;
819- return callback ( wrapper ) ;
814+ if ( wrapper . isA ( object . _t ) ) {
815+ this . loadedTypes [ object . _t ] [ object . _i ] = wrapper ;
816+ callback ( wrapper ) ;
820817 }
821818 } else {
822819 // Replace the value with something that's LOADED
823820 wrapper . object = object ;
824- if ( wrapper . isA ( type ) ) {
825- this . loadedTypes [ type ] [ object . _i ] = wrapper ;
826- return callback ( wrapper ) ;
821+ if ( wrapper . isA ( object . _t ) ) {
822+ this . loadedTypes [ object . _t ] [ object . _i ] = wrapper ;
823+ callback ( wrapper ) ;
827824 }
828825 }
829826 } else {
830827 const wrapper = this . createWrapper ( object , object . _t ) ;
831828 this . objects [ object . _i ] = wrapper ;
832- if ( wrapper . isA ( type ) && object . _s == 1 ) {
833- this . loadedTypes [ type ] [ object . _i ] = wrapper ;
834- return callback ( wrapper ) ;
829+ if ( object . _s == 1 ) {
830+ if ( ! this . loadedTypes [ object . _t ] ) { this . loadedTypes [ object . _t ] = { } }
831+ this . loadedTypes [ object . _t ] [ object . _i ] = wrapper ;
832+ callback ( wrapper ) ;
835833 }
836834 }
837835 } ) ;
0 commit comments