Commit f67b27e0 by David Kaltschmidt

Dont parse empty explore state from url

- only parse url state if there is any
- prevents parse exception in the console on empty explore state
parent a1f0dffe
......@@ -31,18 +31,20 @@ function makeTimeSeriesList(dataList, options) {
});
}
function parseInitialState(initial) {
try {
const parsed = JSON.parse(decodePathComponent(initial));
return {
datasource: parsed.datasource,
queries: parsed.queries.map(q => q.query),
range: parsed.range,
};
} catch (e) {
console.error(e);
return { queries: [], range: DEFAULT_RANGE };
function parseInitialState(initial: string | undefined) {
if (initial) {
try {
const parsed = JSON.parse(decodePathComponent(initial));
return {
datasource: parsed.datasource,
queries: parsed.queries.map(q => q.query),
range: parsed.range,
};
} catch (e) {
console.error(e);
}
}
return { datasource: null, queries: [], range: DEFAULT_RANGE };
}
interface IExploreState {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment