xmcp 6 years ago
parent
commit
f580f1b797
  1. 8
      src/cache.js
  2. 4
      src/flows_api.js
  3. 10
      src/index.js
  4. 2
      src/infrastructure

8
src/cache.js

@ -39,7 +39,7 @@ class Cache {
resolve(null); resolve(null);
} else if(target_version===res.version) { // hit } else if(target_version===res.version) { // hit
console.log('cache hit'); console.log('cache hit');
res.last_access=+new Date(); res.last_access=(+new Date());
store.put(res); store.put(res);
resolve(res.data); resolve(res.data);
} else { // expired } else { // expired
@ -97,4 +97,8 @@ class Cache {
} }
}; };
export let cache=new Cache(); export function cache() {
if(!window._cache)
window._cache=new Cache();
return window._cache;
}

4
src/flows_api.js

@ -27,7 +27,7 @@ export const API={
else throw new Error(JSON.stringify(json)); 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! // also change load_replies_with_cache!
json.data=json.data json.data=json.data
@ -46,7 +46,7 @@ export const API={
load_replies_with_cache: (pid,token,color_picker,cache_version)=> { load_replies_with_cache: (pid,token,color_picker,cache_version)=> {
pid=parseInt(pid); pid=parseInt(pid);
return cache.get(pid,cache_version) return cache().get(pid,cache_version)
.then((json)=>{ .then((json)=>{
if(json) { if(json) {
// also change load_replies! // also change load_replies!

10
src/index.js

@ -2,16 +2,10 @@ import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import './index.css'; import './index.css';
import App from './App'; import App from './App';
//import {elevate} from './infrastructure/elevator';
//import registerServiceWorker from './registerServiceWorker'; //import registerServiceWorker from './registerServiceWorker';
if(window.location.search.indexOf('user_token=')!==-1) //elevate();
window.history.replaceState({},'?','?');
ReactDOM.render(<App />, document.getElementById('root')); ReactDOM.render(<App />, document.getElementById('root'));
//registerServiceWorker(); //registerServiceWorker();
if(navigator.serviceWorker && navigator.serviceWorker.getRegistrations)
navigator.serviceWorker.getRegistrations()
.then(function(registrations) {
for(let registration of registrations) {
registration.unregister();
}});

2
src/infrastructure

@ -1 +1 @@
Subproject commit d1b302d3d1366b7075b0a27238abb0fbdf88f2fc Subproject commit 6f4e221d2b0b8b2abe34c78f4da44bc8e4e916b6
Loading…
Cancel
Save