mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-10-31 15:57:30 +03:00 
			
		
		
		
	Minor refactoring in json-schema-lazy
This commit is contained in:
		
							parent
							
								
									c40de56a71
								
							
						
					
					
						commit
						18c3f605a0
					
				|  | @ -35,20 +35,24 @@ export class JsonSchemaLazy { | |||
|     return schema && schema.$ref || this.pointer; | ||||
|   } | ||||
| 
 | ||||
|   load() { | ||||
|     if (this.optionsService.options.disableLazySchemas) return; | ||||
|     if (this.loaded) return; | ||||
|     if (this.pointer) { | ||||
|       this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { | ||||
|   _loadAfterSelf() { | ||||
|     return this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { | ||||
|       this.initComponent(compRef); | ||||
|         // trigger change detection
 | ||||
|       if (compRef.changeDetectorRef) { | ||||
|         compRef.changeDetectorRef.detectChanges(); | ||||
|       } else { | ||||
|         compRef.hostView.changeDetectorRef.detectChanges(); | ||||
|       } | ||||
|       return compRef; | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   load() { | ||||
|     if (this.optionsService.options.disableLazySchemas) return; | ||||
|     if (this.loaded) return; | ||||
|     if (this.pointer) { | ||||
|       this._loadAfterSelf(); | ||||
|     } | ||||
|     this.loaded = true; | ||||
|   } | ||||
| 
 | ||||
|  | @ -63,29 +67,13 @@ export class JsonSchemaLazy { | |||
|           // skip caching view with tabs inside (discriminator) as it needs attached controller
 | ||||
|           // FIXME: get rid of dependency on selector
 | ||||
|           if ($element.querySelector('.discriminator-wrap')) { | ||||
|             this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { | ||||
|               this.initComponent(compRef); | ||||
|               if (compRef.changeDetectorRef) { | ||||
|                 compRef.changeDetectorRef.detectChanges(); | ||||
|               } else { | ||||
|                 compRef.hostView.changeDetectorRef.detectChanges(); | ||||
|               } | ||||
|             }); | ||||
|             return; | ||||
|           } | ||||
|           insertAfter($element.cloneNode(true), this.elementRef.nativeElement); | ||||
|         } ); | ||||
|       }); | ||||
|     } else { | ||||
|       cache[this.pointer] = this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { | ||||
|         this.initComponent(compRef); | ||||
|         if (compRef.changeDetectorRef) { | ||||
|           compRef.changeDetectorRef.detectChanges(); | ||||
|         } else { | ||||
|           compRef.hostView.changeDetectorRef.detectChanges(); | ||||
|         } | ||||
|         return compRef; | ||||
|       }); | ||||
|       cache[this.pointer] = this._loadAfterSelf(); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user