From f580f1b797d89cd0f17bf2ecbb01ca737f128527 Mon Sep 17 00:00:00 2001 From: xmcp Date: Sun, 18 Aug 2019 16:05:37 +0800 Subject: [PATCH] update --- src/cache.js | 8 ++++++-- src/flows_api.js | 4 ++-- src/index.js | 10 ++-------- src/infrastructure | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/cache.js b/src/cache.js index d470ba8..44bbf61 100644 --- a/src/cache.js +++ b/src/cache.js @@ -39,7 +39,7 @@ class Cache { resolve(null); } else if(target_version===res.version) { // hit console.log('cache hit'); - res.last_access=+new Date(); + res.last_access=(+new Date()); store.put(res); resolve(res.data); } else { // expired @@ -97,4 +97,8 @@ class Cache { } }; -export let cache=new Cache(); \ No newline at end of file +export function cache() { + if(!window._cache) + window._cache=new Cache(); + return window._cache; +} \ No newline at end of file diff --git a/src/flows_api.js b/src/flows_api.js index fbc1b83..1027c68 100644 --- a/src/flows_api.js +++ b/src/flows_api.js @@ -27,7 +27,7 @@ export const API={ else throw new Error(JSON.stringify(json)); } - cache.put(pid,cache_version,json); + cache().put(pid,cache_version,json); // also change load_replies_with_cache! json.data=json.data @@ -46,7 +46,7 @@ export const API={ load_replies_with_cache: (pid,token,color_picker,cache_version)=> { pid=parseInt(pid); - return cache.get(pid,cache_version) + return cache().get(pid,cache_version) .then((json)=>{ if(json) { // also change load_replies! diff --git a/src/index.js b/src/index.js index d2f92bb..987f085 100644 --- a/src/index.js +++ b/src/index.js @@ -2,16 +2,10 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; +//import {elevate} from './infrastructure/elevator'; //import registerServiceWorker from './registerServiceWorker'; -if(window.location.search.indexOf('user_token=')!==-1) - window.history.replaceState({},'?','?'); +//elevate(); ReactDOM.render(, document.getElementById('root')); //registerServiceWorker(); -if(navigator.serviceWorker && navigator.serviceWorker.getRegistrations) - navigator.serviceWorker.getRegistrations() - .then(function(registrations) { - for(let registration of registrations) { - registration.unregister(); - }}); \ No newline at end of file diff --git a/src/infrastructure b/src/infrastructure index d1b302d..6f4e221 160000 --- a/src/infrastructure +++ b/src/infrastructure @@ -1 +1 @@ -Subproject commit d1b302d3d1366b7075b0a27238abb0fbdf88f2fc +Subproject commit 6f4e221d2b0b8b2abe34c78f4da44bc8e4e916b6