forked from newthuhole/hole_thu_frontend
update
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
@@ -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
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();
|
|
||||||
}});
|
|
||||||
Submodule src/infrastructure updated: d1b302d3d1...6f4e221d2b
Reference in New Issue
Block a user