Prevent components from being defined multiple times (#1627)

This commit is contained in:
Matt Irvine
2018-06-13 16:51:06 -07:00
committed by GitHub
parent 30b111034d
commit e9661f90d0

View File

@@ -40,7 +40,6 @@ export abstract class ViewBase extends AngularDisposable implements IModelView {
abstract serverInfo: sqlops.ServerInfo;
private _onEventEmitter = new Emitter<any>();
initializeModel(rootComponent: IComponentShape, validationCallback: (componentId: string) => Thenable<boolean>): void {
let descriptor = this.defineComponent(rootComponent);
this.rootDescriptor = descriptor;
@@ -50,6 +49,10 @@ export abstract class ViewBase extends AngularDisposable implements IModelView {
}
private defineComponent(component: IComponentShape): IComponentDescriptor {
let existingDescriptor = this.modelStore.getComponentDescriptor(component.id);
if (existingDescriptor) {
return existingDescriptor;
}
let typeId = componentRegistry.getIdForTypeMapping(component.type);
if (!typeId) {
// failure case