Ensure the LocalStroage keys are valid.
Also update the cache key name.
This commit is contained in:
parent
afccb144b1
commit
4d4e9a063e
1 changed files with 11 additions and 2 deletions
|
@ -94,8 +94,8 @@ var getInitStatus = (function() {
|
||||||
|
|
||||||
var PvCache = (function() {
|
var PvCache = (function() {
|
||||||
const KEY_PV = "pv";
|
const KEY_PV = "pv";
|
||||||
const KEY_CREATION = "pv-created-date";
|
const KEY_CREATION = "pv_created_date";
|
||||||
const KEY_PV_TYPE = "pv-type";
|
const KEY_PV_TYPE = "pv_type";
|
||||||
|
|
||||||
var PvType = {
|
var PvType = {
|
||||||
ORIGIN: "origin",
|
ORIGIN: "origin",
|
||||||
|
@ -148,6 +148,13 @@ var PvCache = (function() {
|
||||||
},
|
},
|
||||||
newerThan: function(pv) {
|
newerThan: function(pv) {
|
||||||
return PvCache.getAllPagevies() > pv.totalsForAllResults["ga:pageviews"];
|
return PvCache.getAllPagevies() > pv.totalsForAllResults["ga:pageviews"];
|
||||||
|
},
|
||||||
|
inspectKeys: function() {
|
||||||
|
if (localStorage.getItem(KEY_PV) == null
|
||||||
|
|| localStorage.getItem(KEY_PV_TYPE) == null
|
||||||
|
|| localStorage.getItem(KEY_CREATION) == null) {
|
||||||
|
localStorage.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -184,6 +191,8 @@ $(function() {
|
||||||
|
|
||||||
if ($('.pageviews').length > 0) {
|
if ($('.pageviews').length > 0) {
|
||||||
|
|
||||||
|
PvCache.inspectKeys();
|
||||||
|
|
||||||
let cache = PvCache.getData();
|
let cache = PvCache.getData();
|
||||||
|
|
||||||
if (cache) {
|
if (cache) {
|
||||||
|
|
Loading…
Reference in a new issue