Skip to content

Commit

Permalink
Added logic to reload docs on app load.
Browse files Browse the repository at this point in the history
Closes #1145.
  • Loading branch information
imolorhe committed Jan 3, 2020
1 parent 27de737 commit 73939fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/app/reducers/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ export interface State {
* Specifies if requests should be sent with credentials (with cookies) or not
*/
'request.withCredentials'?: boolean;

/**
* Specifies if the schema should be reloaded when the app starts
*/
'schema.reloadOnStart'?: boolean;
}

export const getInitialState = (): State => {
Expand Down
11 changes: 10 additions & 1 deletion src/app/services/window.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import {of as observableOf, Subscription, Observable, Observer } from 'rxjs';

import { first, tap } from 'rxjs/operators';
import { first, tap, map } from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';

Expand Down Expand Up @@ -330,6 +330,15 @@ export class WindowService {
this.store.dispatch(new queryActions.StopSubscriptionAction(windowId));
this.store.dispatch(new streamActions.StopStreamClientAction(windowId));
this.store.dispatch(new streamActions.StartStreamClientAction(windowId));

this.store.pipe(
first(),
map(data => data.settings['schema.reloadOnStart']),
).subscribe(shouldReloadSchema => {
if (shouldReloadSchema) {
this.store.dispatch(new queryActions.SendIntrospectionQueryRequestAction(windowId));
}
});
}
private cleanupWindow(windowId: string) {
this.store.dispatch(new queryActions.StopSubscriptionAction(windowId));
Expand Down

0 comments on commit 73939fc

Please sign in to comment.