Added a list for events to not fire an WINDOW_OUT event after sdc notifies about them
Small fix to Plugins loader
Change-Id: Ia31ebf4095b94a5ca602c4f502df4fcc32368b0b
Issue-ID: SDC-1277
Signed-off-by: Idan Amit <ia096e@intl.att.com>
eventsCallbacks: Array<Function>;
clientId: string;
eventsToWait: Map<string, Array<string>>;
+ lastEventNotified: string;
constructor(pluginId: string) {
this.subscribers = new Map<string, ISubscriber>();
this.eventsCallbacks = [];
this.eventsToWait = new Map<string, Array<string>>();
this.clientId = pluginId;
+ this.lastEventNotified = "";
this.onMessage = this.onMessage.bind(this);
window.addEventListener("message", this.onMessage);
this.subscribers.forEach( (subscriber: ISubscriber, subscriberId: string) => {
subscriber.window.postMessage(eventObj, subscriber.locationUrl);
-
});
+ this.lastEventNotified = eventType;
+
return {
subscribe: function(callbackFn) {
// before moving to a new state
this.$scope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams) => {
if ((fromState.name !== toState.name) || (fromState.name === toState.name) && (toParams.path !== fromParams.path)) {
- if (!this.isClosed) {
- event.preventDefault();
+ if(this.eventBusService.NoWindowOutEvents.indexOf(this.eventBusService.lastEventNotified) == -1) {
+ if (!this.isClosed) {
+ event.preventDefault();
- this.eventBusService.notify("WINDOW_OUT").subscribe(() => {
- this.isClosed = true;
- this.eventBusService.unregister(this.plugin.pluginId);
+ this.eventBusService.notify("WINDOW_OUT").subscribe(() => {
+ this.isClosed = true;
+ this.eventBusService.unregister(this.plugin.pluginId);
- this.$state.go(toState.name, toParams);
- });
+ this.$state.go(toState.name, toParams);
+ });
+ }
+ }
+ else {
+ this.eventBusService.unregister(this.plugin.pluginId);
}
}
});
@Injectable()
export class EventBusService extends BasePubSub {
+ NoWindowOutEvents: Array<string>;
+
constructor() {
super("sdc-hub");
+ this.NoWindowOutEvents = ["CHECK_IN", "SUBMIT_FOR_TESTING", "UNDO_CHECK_OUT"];
}
protected handlePluginRegistration(eventData: IPubSubEvent, event: any) {
-<loader display="isLoading"></loader>
+<loader display="isLoading && plugin.isOnline" ></loader>
<div class="workspace-plugins">
<plugin-frame (on-loading-done)="onLoadingDone(plugin)" [plugin]="plugin" [query-params]="queryParams"></plugin-frame>
</div>