Remove cache store
This commit is contained in:
@@ -20,12 +20,11 @@ import styles from './DocumentScene.scss';
|
||||
// const cx = classNames.bind(styles);
|
||||
|
||||
@keydown(['cmd+/', 'ctrl+/', 'c', 'e'])
|
||||
@inject('ui', 'cache')
|
||||
@inject('ui')
|
||||
@observer
|
||||
class DocumentScene extends React.Component {
|
||||
static propTypes = {
|
||||
ui: PropTypes.object.isRequired,
|
||||
cache: PropTypes.object.isRequired,
|
||||
routeParams: PropTypes.object,
|
||||
params: PropTypes.object.isRequired,
|
||||
location: PropTypes.object.isRequired,
|
||||
@@ -34,10 +33,7 @@ class DocumentScene extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.store = new DocumentSceneStore(
|
||||
JSON.parse(localStorage[DOCUMENT_PREFERENCES] || '{}'),
|
||||
{
|
||||
cache: this.props.cache,
|
||||
}
|
||||
JSON.parse(localStorage[DOCUMENT_PREFERENCES] || '{}')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ import { browserHistory } from 'react-router';
|
||||
const DOCUMENT_PREFERENCES = 'DOCUMENT_PREFERENCES';
|
||||
|
||||
class DocumentSceneStore {
|
||||
static cache;
|
||||
|
||||
@observable document;
|
||||
@observable collapsedNodes = [];
|
||||
|
||||
@@ -53,18 +51,12 @@ class DocumentSceneStore {
|
||||
replaceUrl: true,
|
||||
...options,
|
||||
};
|
||||
let cacheHit = false;
|
||||
runInAction('retrieve document from cache', () => {
|
||||
const cachedValue = this.cache.fetchFromCache(id);
|
||||
cacheHit = !!cachedValue;
|
||||
if (cacheHit) this.document = cachedValue;
|
||||
});
|
||||
|
||||
this.isFetching = !options.softLoad;
|
||||
this.updatingContent = options.softLoad && !cacheHit;
|
||||
this.updatingContent = true;
|
||||
|
||||
try {
|
||||
const res = await client.get('/documents.info', { id }, { cache: true });
|
||||
const res = await client.get('/documents.info', { id });
|
||||
const { data } = res;
|
||||
runInAction('fetchDocument', () => {
|
||||
this.document = data;
|
||||
@@ -131,7 +123,6 @@ class DocumentSceneStore {
|
||||
constructor(settings, options) {
|
||||
// Rehydrate settings
|
||||
this.collapsedNodes = settings.collapsedNodes || [];
|
||||
this.cache = options.cache;
|
||||
|
||||
// Persist settings to localStorage
|
||||
// TODO: This could be done more selectively
|
||||
|
||||
Reference in New Issue
Block a user