Skip to content

Commit

Permalink
Reload schema on environment change
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Dec 15, 2024
1 parent 9618187 commit 1315720
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
withLatestFrom,
} from 'rxjs/operators';
import { Component, Input, OnInit } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { Store, createSelector, select } from '@ngrx/store';

import * as fromRoot from '../../store';

Expand Down Expand Up @@ -329,6 +329,28 @@ export class WindowComponent implements OnInit {
}
});

// Reload the schema when the environment changes
this.store
.select(
createSelector(
fromRoot.getActiveSubEnvironmentState,
(state) => state.settings['schema.reload.onEnvChange'],
(activeEnvironment, reloadOnChange) => {
if (reloadOnChange) {
return activeEnvironment;
}

return null;
}
)
)
.pipe(untilDestroyed(this))
.subscribe((dt) => {
if (dt !== null) {
this.reloadDocs();
}
});

this.windowService.setupWindow(this.windowId);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/altair-core/src/types/state/settings.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ export interface SettingsState {
*/
'schema.reloadOnStart'?: boolean;

/**
* Reload schema when switching environments
*/
'schema.reload.onEnvChange'?: boolean;

/**
* Disable update notification
*/
Expand Down
3 changes: 2 additions & 1 deletion test-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
"nodemon": "^2.0.22",
"ts-node": "^10.9.1",
"typescript": "5.2.2"
}
},
"packageManager": "[email protected]"
}
Loading

0 comments on commit 1315720

Please sign in to comment.