mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Remove state history cache from window (#1193)
This commit is contained in:
parent
0789c0884c
commit
41990767e2
@ -13,7 +13,7 @@ import LocalizeMixin from '../mixins/localize-mixin.js';
|
|||||||
const RECENT_CACHE = {};
|
const RECENT_CACHE = {};
|
||||||
const DOMAINS_USE_LAST_UPDATED = ['thermostat', 'climate'];
|
const DOMAINS_USE_LAST_UPDATED = ['thermostat', 'climate'];
|
||||||
const LINE_ATTRIBUTES_TO_KEEP = ['temperature', 'current_temperature', 'target_temp_low', 'target_temp_high'];
|
const LINE_ATTRIBUTES_TO_KEEP = ['temperature', 'current_temperature', 'target_temp_low', 'target_temp_high'];
|
||||||
window.stateHistoryCache = window.stateHistoryCache || {};
|
const stateHistoryCache = {};
|
||||||
|
|
||||||
function computeHistory(stateHistory, localize, language) {
|
function computeHistory(stateHistory, localize, language) {
|
||||||
const lineChartDevices = {};
|
const lineChartDevices = {};
|
||||||
@ -295,7 +295,7 @@ import LocalizeMixin from '../mixins/localize-mixin.js';
|
|||||||
originalStartTime.setHours(originalStartTime.getHours() - cacheConfig.hoursToShow);
|
originalStartTime.setHours(originalStartTime.getHours() - cacheConfig.hoursToShow);
|
||||||
let startTime = originalStartTime;
|
let startTime = originalStartTime;
|
||||||
let appendingToCache = false;
|
let appendingToCache = false;
|
||||||
let cache = window.stateHistoryCache[cacheKey];
|
let cache = stateHistoryCache[cacheKey];
|
||||||
if (cache && startTime >= cache.startTime && startTime <= cache.endTime
|
if (cache && startTime >= cache.startTime && startTime <= cache.endTime
|
||||||
&& cache.language === language) {
|
&& cache.language === language) {
|
||||||
startTime = cache.endTime;
|
startTime = cache.endTime;
|
||||||
@ -304,7 +304,7 @@ import LocalizeMixin from '../mixins/localize-mixin.js';
|
|||||||
return cache.prom;
|
return cache.prom;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cache = window.stateHistoryCache[cacheKey] = this.getEmptyCache(language);
|
cache = stateHistoryCache[cacheKey] = this.getEmptyCache(language);
|
||||||
}
|
}
|
||||||
// Use Promise.all in order to make sure the old and the new fetches have both completed.
|
// Use Promise.all in order to make sure the old and the new fetches have both completed.
|
||||||
const prom = Promise.all([cache.prom,
|
const prom = Promise.all([cache.prom,
|
||||||
@ -325,7 +325,7 @@ import LocalizeMixin from '../mixins/localize-mixin.js';
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
console.error(err);
|
console.error(err);
|
||||||
window.stateHistoryCache[cacheKey] = undefined;
|
stateHistoryCache[cacheKey] = undefined;
|
||||||
});
|
});
|
||||||
cache.prom = prom;
|
cache.prom = prom;
|
||||||
cache.startTime = originalStartTime;
|
cache.startTime = originalStartTime;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user