mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
Decorate rackt/history with history of previous locations
Could be turned into a createHistory enhancer function (https://github.com/rackt/history/blob/master/docs/Glossary.md#createhis toryenhancer), but we’ll see what the guys at rackt/history say about it…
This commit is contained in:
parent
2acf3f4056
commit
fce578e854
@ -1,11 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { History } from 'react-router';
|
||||||
|
|
||||||
import Header from '../components/header';
|
import Header from './header';
|
||||||
import Footer from '../components/footer';
|
import Footer from './footer';
|
||||||
import GlobalNotification from './global_notification';
|
import GlobalNotification from './global_notification';
|
||||||
|
|
||||||
|
import AppConstants from '../constants/application_constants';
|
||||||
|
|
||||||
|
|
||||||
let AscribeApp = React.createClass({
|
let AscribeApp = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -13,11 +16,28 @@ let AscribeApp = React.createClass({
|
|||||||
React.PropTypes.arrayOf(React.PropTypes.element),
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
||||||
React.PropTypes.element
|
React.PropTypes.element
|
||||||
]),
|
]),
|
||||||
routes: React.PropTypes.arrayOf(React.PropTypes.object)
|
routes: React.PropTypes.arrayOf(React.PropTypes.object),
|
||||||
|
location: React.PropTypes.object
|
||||||
|
},
|
||||||
|
|
||||||
|
mixins: [History],
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.history.locationQueue.push(this.props.location);
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
const { locationQueue } = this.history;
|
||||||
|
locationQueue.unshift(nextProps.location);
|
||||||
|
|
||||||
|
// Limit the number of locations to keep in memory to avoid too much memory usage
|
||||||
|
if (locationQueue.length > AppConstants.locationThreshold) {
|
||||||
|
locationQueue.length = AppConstants.locationThreshold;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { children, routes } = this.props;
|
const { children, routes } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container ascribe-default-app">
|
<div className="container ascribe-default-app">
|
||||||
|
@ -104,6 +104,8 @@ const constants = {
|
|||||||
'IVARO', 'SIAE', 'JASPAR-SPDA', 'AKKA/LAA', 'LATGA-A', 'SOMAAP', 'ARTEGESTION', 'CARIER', 'BONO', 'APSAV',
|
'IVARO', 'SIAE', 'JASPAR-SPDA', 'AKKA/LAA', 'LATGA-A', 'SOMAAP', 'ARTEGESTION', 'CARIER', 'BONO', 'APSAV',
|
||||||
'SPA', 'GESTOR', 'VISaRTA', 'RAO', 'LITA', 'DALRO', 'VeGaP', 'BUS', 'ProLitteris', 'AGADU', 'AUTORARTE', 'BUBEDRA', 'BBDA', 'BCDA', 'BURIDA', 'ADAVIS', 'BSDA'],
|
'SPA', 'GESTOR', 'VISaRTA', 'RAO', 'LITA', 'DALRO', 'VeGaP', 'BUS', 'ProLitteris', 'AGADU', 'AUTORARTE', 'BUBEDRA', 'BBDA', 'BCDA', 'BURIDA', 'ADAVIS', 'BSDA'],
|
||||||
|
|
||||||
|
'locationThreshold': 10,
|
||||||
|
|
||||||
'searchThreshold': 500,
|
'searchThreshold': 500,
|
||||||
|
|
||||||
'supportedThumbnailFileFormats': [
|
'supportedThumbnailFileFormats': [
|
||||||
|
@ -6,8 +6,12 @@ import AppConstants from './constants/application_constants';
|
|||||||
|
|
||||||
|
|
||||||
// Remove the trailing slash if present
|
// Remove the trailing slash if present
|
||||||
let baseUrl = AppConstants.baseUrl.replace(/\/$/, '');
|
const baseUrl = AppConstants.baseUrl.replace(/\/$/, '');
|
||||||
|
|
||||||
export default useBasename(createBrowserHistory)({
|
const history = useBasename(createBrowserHistory)({
|
||||||
basename: baseUrl
|
basename: baseUrl
|
||||||
});
|
});
|
||||||
|
|
||||||
|
history.locationQueue = [];
|
||||||
|
|
||||||
|
export default history;
|
||||||
|
Loading…
Reference in New Issue
Block a user