diff --git a/src/plugins/newsfeed/public/plugin.tsx b/src/plugins/newsfeed/public/plugin.tsx index 2877c63435d4b..c4e042fe452f9 100644 --- a/src/plugins/newsfeed/public/plugin.tsx +++ b/src/plugins/newsfeed/public/plugin.tsx @@ -26,7 +26,6 @@ import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core import { FetchResult, NewsfeedPluginInjectedConfig } from '../types'; import { NewsfeedNavButton, NewsfeedApiFetchResult } from './components/newsfeed_header_nav_button'; import { getApi } from './lib/api'; -import { Observable } from 'rxjs'; export type Setup = void; export type Start = void; @@ -54,16 +53,19 @@ export class NewsfeedPublicPlugin implements Plugin { } private fetchNewsfeed(core: CoreStart) { - // const { http, injectedMetadata } = core; - // const config = injectedMetadata.getInjectedVar( - // 'newsfeed' - // ) as NewsfeedPluginInjectedConfig['newsfeed']; - // - return new Observable(); - // return getApi(http, config, this.kibanaVersion).pipe( - // takeUntil(this.stop$), // stop the interval when stop method is called - // catchError(() => Rx.of(null)) // do not throw error - // ); + const { http, injectedMetadata } = core; + const config = injectedMetadata.getInjectedVar('newsfeed') as + | NewsfeedPluginInjectedConfig['newsfeed'] + | undefined; + + if (!config) { + // running in new platform, injected metadata not available + return new Rx.Observable(); + } + return getApi(http, config, this.kibanaVersion).pipe( + takeUntil(this.stop$), // stop the interval when stop method is called + catchError(() => Rx.of(null)) // do not throw error + ); } private mount(api$: NewsfeedApiFetchResult, targetDomElement: HTMLElement) {