Skip to content

Commit 7ecae68

Browse files
committed
fix(QueryStringManager): Could not subscribe to application.currentAppId$
Partially revert opensearch-project#9466. Current implementation doesn't work because QueryStringManager is constructed during setup, and setApplication happens during start. In playground or any instance we see `Could not subscribe to application.currentAppId$` in console warning. Signed-off-by: Joshua Li <[email protected]>
1 parent 7f80625 commit 7ecae68

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/plugins/data/public/query/query_string/query_string_manager.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export class QueryStringManager {
4545
private queryHistory: QueryHistory;
4646
private datasetService!: DatasetServiceContract;
4747
private languageService!: LanguageServiceContract;
48-
private currentAppId: string | undefined;
4948

5049
constructor(
5150
private readonly storage: DataStorage,
@@ -58,17 +57,6 @@ export class QueryStringManager {
5857
this.queryHistory = createHistory({ storage: this.sessionStorage });
5958
this.datasetService = new DatasetService(uiSettings, this.sessionStorage);
6059
this.languageService = new LanguageService(this.defaultSearchInterceptor, this.storage);
61-
try {
62-
const application = getApplication();
63-
if (application && application.currentAppId$) {
64-
application.currentAppId$.subscribe((appId) => {
65-
this.currentAppId = appId;
66-
});
67-
}
68-
} catch (error) {
69-
// eslint-disable-next-line no-console
70-
console.warn('Could not subscribe to application.currentAppId$');
71-
}
7260
}
7361

7462
private getDefaultQueryString() {
@@ -361,15 +349,20 @@ export class QueryStringManager {
361349
return this.uiSettings.get(UI_SETTINGS.SEARCH_QUERY_LANGUAGE);
362350
}
363351

364-
private getCurrentAppId(): string | undefined {
352+
private getCurrentAppId = () => {
353+
let appId;
365354
try {
366-
return this.currentAppId;
355+
const application = getApplication();
356+
if (application) {
357+
application.currentAppId$.subscribe((val) => (appId = val)).unsubscribe();
358+
}
367359
} catch (err) {
368360
// eslint-disable-next-line no-console
369361
console.error('Application Not available.');
370362
}
371-
return undefined;
372-
}
363+
364+
return appId;
365+
};
373366
}
374367

375368
const showWarning = (

0 commit comments

Comments
 (0)