Fix edit annotation rendering speed

The editTemplateVariableNames action would fire way too many times.
This cause poor rendering speeds with annotations.
pull/3159/head
Andrew Watkins 2018-04-09 20:07:43 -07:00
parent 919e14a7ec
commit 37b50cb956
1 changed files with 20 additions and 12 deletions

View File

@ -4,19 +4,27 @@ import queryString from 'query-string'
import {enablePresentationMode} from 'src/shared/actions/app'
import {templateVariablesSelectedByName} from 'src/dashboards/actions'
export const queryStringConfig = () => next => action => {
next(action)
const qs = queryString.parse(window.location.search)
export const queryStringConfig = () => {
let prevPath
return next => action => {
next(action)
const qs = queryString.parse(window.location.search)
// Presentation Mode
if (qs.present === 'true') {
next(enablePresentationMode())
}
// Presentation Mode
if (qs.present === 'true') {
next(enablePresentationMode())
}
// Select Template Variable By Name
const dashboardRegex = /\/sources\/(\d+?)\/dashboards\/(\d+?)/
if (dashboardRegex.test(window.location.pathname)) {
const dashboardID = window.location.pathname.match(dashboardRegex)[2]
next(templateVariablesSelectedByName(+dashboardID, qs))
// Select Template Variable By Name
const dashboardRegex = /\/sources\/(\d+?)\/dashboards\/(\d+?)/
if (dashboardRegex.test(window.location.pathname)) {
const currentPath = window.location.pathname
const dashboardID = currentPath.match(dashboardRegex)[2]
if (currentPath !== prevPath) {
next(templateVariablesSelectedByName(+dashboardID, qs))
}
prevPath = currentPath
}
}
}