Normalize dashboard time ranges on load and save to localStorage

pull/10616/head
Andrew Watkins 2017-10-05 17:24:15 -07:00
parent 8d7d0bd254
commit 1656d2e8f2
1 changed files with 20 additions and 3 deletions

View File

@ -1,3 +1,5 @@
import normalizer from 'src/normalizers/dashboardTime'
export const loadLocalStorage = errorsQueue => {
try {
const serializedState = localStorage.getItem('state')
@ -12,8 +14,22 @@ export const loadLocalStorage = errorsQueue => {
console.log(errorText) // eslint-disable-line no-console
errorsQueue.push(errorText)
window.localStorage.removeItem('state')
return {}
if (!state.dashTimeV1) {
window.localStorage.removeItem('state')
return {}
}
const ranges = normalizer(state.dashTimeV1.ranges)
const dashTimeV1 = {ranges}
window.localStorage.setItem(
'state',
JSON.stringify({
dashTimeV1,
})
)
return {dashTimeV1}
}
delete state.VERSION
@ -34,10 +50,11 @@ export const saveToLocalStorage = ({
dataExplorerQueryConfigs,
timeRange,
dataExplorer,
dashTimeV1,
dashTimeV1: {ranges},
}) => {
try {
const appPersisted = Object.assign({}, {app: {persisted}})
const dashTimeV1 = {ranges: normalizer(ranges)}
window.localStorage.setItem(
'state',