diff --git a/public/app/features/live/live.ts b/public/app/features/live/live.ts index d3f44e616de..267d3065211 100644 --- a/public/app/features/live/live.ts +++ b/public/app/features/live/live.ts @@ -214,23 +214,11 @@ export class CentrifugeSrv implements GrafanaLiveSrv { return new Observable((subscriber) => { const channel = this.getChannel(options.addr); + const key = options.key ?? `xstr/${streamCounter++}`; let data: StreamingDataFrame | undefined = undefined; let filtered: DataFrame | undefined = undefined; - let state = LoadingState.Loading; - let { key } = options; + let state = LoadingState.Streaming; let last = perf.last; - if (options.frame) { - const msg = dataFrameToJSON(options.frame); - data = new StreamingDataFrame(msg, options.buffer); - state = LoadingState.Streaming; - } - if (channel.lastMessageWithSchema && !data) { - data = new StreamingDataFrame(channel.lastMessageWithSchema, options.buffer); - } - - if (!key) { - key = `xstr/${streamCounter++}`; - } const process = (msg: DataFrameJSON) => { if (!data) { @@ -262,6 +250,12 @@ export class CentrifugeSrv implements GrafanaLiveSrv { } }; + if (options.frame) { + process(dataFrameToJSON(options.frame)); + } else if (channel.lastMessageWithSchema) { + process(channel.lastMessageWithSchema); + } + const sub = channel.getStream().subscribe({ error: (err: any) => { console.log('LiveQuery [error]', { err }, options.addr);