Skip to content

Commit

Permalink
fix update loop
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Mar 23, 2023
1 parent fdd1f8f commit b758a25
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*ngIf="account?.loggedIn"
>
<h3>
<app-icon name="flask-conical"></app-icon> {{ 'ACCOUNT_TITLE' | translate }} (Alpha)
<app-icon name="flask-conical"></app-icon> {{ 'ACCOUNT_TITLE' | translate }} (Beta)
</h3>
<p>Hello, {{ account?.firstName }}</p>
<p>
Expand Down
190 changes: 91 additions & 99 deletions packages/altair-app/src/app/modules/altair/services/window.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,108 +254,100 @@ export class WindowService {
}

updateWindowState(windowId: string, data: ExportWindowState) {
this.getWindowState(windowId).subscribe((window) => {
this.store.dispatch(
new layoutActions.SetWindowNameAction(windowId, {
title: data.windowName,
setByUser: true,
})
);

if (data.apiUrl && data.apiUrl !== window?.query.url) {
this.store.dispatch(
new queryActions.SetUrlAction({ url: data.apiUrl }, windowId)
);
this.store.dispatch(
new queryActions.SendIntrospectionQueryRequestAction(windowId)
);
}

if (data.query) {
this.store.dispatch(
new queryActions.SetQueryAction(data.query, windowId)
);
}

if (data.headers.length) {
this.store.dispatch(
new headerActions.SetHeadersAction(
{ headers: data.headers },
windowId
)
);
}

if (data.variables) {
this.store.dispatch(
new variableActions.UpdateVariablesAction(data.variables, windowId)
);
this.store.dispatch(
new dialogsActions.ToggleVariableDialogAction(windowId)
);
}

if (data.subscriptionUrl) {
this.store.dispatch(
new queryActions.SetSubscriptionUrlAction(
{ subscriptionUrl: data.subscriptionUrl },
windowId
)
);
}

if (data.subscriptionConnectionParams) {
this.store.dispatch(
new queryActions.SetSubscriptionConnectionParamsAction(windowId, {
connectionParams: data.subscriptionConnectionParams,
})
);
}

if (data.subscriptionProvider) {
this.store.dispatch(
new queryActions.SetSubscriptionProviderIdAction(windowId, {
providerId: data.subscriptionProvider,
})
);
}

if (data.preRequestScriptEnabled) {
this.store.dispatch(
new preRequestActions.SetPreRequestEnabledAction(windowId, {
enabled: data.preRequestScriptEnabled,
})
);
}
if (data.preRequestScript) {
this.store.dispatch(
new preRequestActions.SetPreRequestScriptAction(windowId, {
script: data.preRequestScript,
})
);
}

if (data.postRequestScriptEnabled) {
this.store.dispatch(
new postRequestActions.SetPostRequestEnabledAction(windowId, {
enabled: data.postRequestScriptEnabled,
})
);
}
if (data.postRequestScript) {
this.getWindowState(windowId)
.pipe(take(1))
.subscribe((window) => {
this.store.dispatch(
new postRequestActions.SetPostRequestScriptAction(windowId, {
script: data.postRequestScript,
new layoutActions.SetWindowNameAction(windowId, {
title: data.windowName,
setByUser: true,
})
);
}

if (data.gqlSchema) {
this.store.dispatch(
new gqlSchemaActions.SetSchemaAction(windowId, data.gqlSchema)
);
}
});
if (data.apiUrl && data.apiUrl !== window?.query.url) {
this.store.dispatch(
new queryActions.SetUrlAction({ url: data.apiUrl }, windowId)
);
this.store.dispatch(
new queryActions.SendIntrospectionQueryRequestAction(windowId)
);
}
if (data.query) {
this.store.dispatch(
new queryActions.SetQueryAction(data.query, windowId)
);
}
if (data.headers.length) {
this.store.dispatch(
new headerActions.SetHeadersAction(
{ headers: data.headers },
windowId
)
);
}
if (data.variables) {
this.store.dispatch(
new variableActions.UpdateVariablesAction(data.variables, windowId)
);
this.store.dispatch(
new dialogsActions.ToggleVariableDialogAction(windowId)
);
}
if (data.subscriptionUrl) {
this.store.dispatch(
new queryActions.SetSubscriptionUrlAction(
{ subscriptionUrl: data.subscriptionUrl },
windowId
)
);
}
if (data.subscriptionConnectionParams) {
this.store.dispatch(
new queryActions.SetSubscriptionConnectionParamsAction(windowId, {
connectionParams: data.subscriptionConnectionParams,
})
);
}
if (data.subscriptionProvider) {
this.store.dispatch(
new queryActions.SetSubscriptionProviderIdAction(windowId, {
providerId: data.subscriptionProvider,
})
);
}
if (data.preRequestScriptEnabled) {
this.store.dispatch(
new preRequestActions.SetPreRequestEnabledAction(windowId, {
enabled: data.preRequestScriptEnabled,
})
);
}
if (data.preRequestScript) {
this.store.dispatch(
new preRequestActions.SetPreRequestScriptAction(windowId, {
script: data.preRequestScript,
})
);
}
if (data.postRequestScriptEnabled) {
this.store.dispatch(
new postRequestActions.SetPostRequestEnabledAction(windowId, {
enabled: data.postRequestScriptEnabled,
})
);
}
if (data.postRequestScript) {
this.store.dispatch(
new postRequestActions.SetPostRequestScriptAction(windowId, {
script: data.postRequestScript,
})
);
}
if (data.gqlSchema) {
this.store.dispatch(
new gqlSchemaActions.SetSchemaAction(windowId, data.gqlSchema)
);
}
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/altair-app/src/assets/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"PLUGIN_ADD_BUTTON": "Add to Altair",
"PLUGIN_REMOVE_BUTTON": "Remove",
"PLUGIN_CREATE_BUTTON": "Create Plugin",
"ACCOUNT_TITLE": "Account",
"ACCOUNT_TITLE": "Account (Beta)",
"LOGIN_TAB": "Login",
"REGISTER_TAB": "Register",
"LOGOUT_TEXT": "Logout",
Expand Down

0 comments on commit b758a25

Please sign in to comment.