diff options
Diffstat (limited to 'web/src/js/components/common.js')
-rw-r--r-- | web/src/js/components/common.js | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/web/src/js/components/common.js b/web/src/js/components/common.js index 96262acc..3ed035ee 100644 --- a/web/src/js/components/common.js +++ b/web/src/js/components/common.js @@ -32,51 +32,41 @@ var StickyHeadMixin = { var Navigation = _.extend({}, ReactRouter.Navigation, { setQuery: function (dict) { - var q = this.context.getCurrentQuery(); + var q = this.context.router.getCurrentQuery(); for(var i in dict){ if(dict.hasOwnProperty(i)){ q[i] = dict[i] || undefined; //falsey values shall be removed. } } - q._ = "_"; // workaround for https://github.com/rackt/react-router/pull/599 - this.replaceWith(this.context.getCurrentPath(), this.context.getCurrentParams(), q); + q._ = "_"; // workaround for https://github.com/rackt/react-router/pull/957 + this.replaceWith(this.context.router.getCurrentPath(), this.context.router.getCurrentParams(), q); }, replaceWith: function(routeNameOrPath, params, query) { if(routeNameOrPath === undefined){ - routeNameOrPath = this.context.getCurrentPath(); + routeNameOrPath = this.context.router.getCurrentPath(); } if(params === undefined){ - params = this.context.getCurrentParams(); + params = this.context.router.getCurrentParams(); } - if(query === undefined){ - query = this.context.getCurrentQuery(); + if(query === undefined) { + query = this.context.router.getCurrentQuery(); } - ReactRouter.Navigation.replaceWith.call(this, routeNameOrPath, params, query); + + // FIXME: react-router is just broken, + // we hopefully just need to wait for the next release with https://github.com/rackt/react-router/pull/957. + this.context.router.replaceWith(routeNameOrPath, params, query); } }); -_.extend(Navigation.contextTypes, ReactRouter.State.contextTypes); +// react-router is fairly good at changing its API regularly. +// We keep the old method for now - if it should turn out that their changes are permanent, +// we may remove this mixin and access react-router directly again. var State = _.extend({}, ReactRouter.State, { - getInitialState: function () { - this._query = this.context.getCurrentQuery(); - this._queryWatches = []; - return null; - }, - onQueryChange: function (key, callback) { - this._queryWatches.push({ - key: key, - callback: callback - }); + getQuery: function(){ + return this.context.router.getCurrentQuery(); }, - componentWillReceiveProps: function (nextProps, nextState) { - var q = this.context.getCurrentQuery(); - for (var i = 0; i < this._queryWatches.length; i++) { - var watch = this._queryWatches[i]; - if (this._query[watch.key] !== q[watch.key]) { - watch.callback(this._query[watch.key], q[watch.key], watch.key); - } - } - this._query = q; + getParams: function(){ + return this.context.router.getCurrentParams(); } }); @@ -191,4 +181,4 @@ module.exports = { StickyHeadMixin: StickyHeadMixin, AutoScrollMixin: AutoScrollMixin, Splitter: Splitter -}
\ No newline at end of file +};
\ No newline at end of file |