Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dsr.ts DSR using params subset redirecting to the default state #165

Merged
merged 2 commits into from
Dec 26, 2019

Conversation

DavideCordella
Copy link
Contributor

@DavideCordella DavideCordella commented May 17, 2019

Dear All,
I have one root state with a parameter and two substates with the following config:
rootState1, /rootstate1/:rootstate1param, params: [rootstate1param]
rootState2, /rootstate2/:rootstate2param
sub1, rootState1.sub1, /sub1, default
sub2, rootState1.sub2 /sub2/:sub2param

The DSR on rootState1 is configured to consider only rootstate1param.
If I first access sub1 state and then sub2 when I switch from rootState1 to rootState2 and I come back to rootState1 I get redirected to sub1 instead of sub2 like I'd expect being the last accessed state.

I think the issue is in the following function:

DSRPlugin.prototype.recordDeepState = function (transition, state) {

     var _this = this;
    var $state = this.$state;
    var hasParamsConfig = !!this.getConfig(state).params;
    var _state = state.$$state();
    transition.promise.then(function () {
        var transTo = transition.to();
        var triggerParams = transition.params();
        var target = $state.target(transTo, triggerParams);
        var targetStateName = target.name();
        var targetParams = target.params();
        var recordedDSR = { triggerParams: triggerParams, targetStateName: targetStateName, targetParams: targetParams };
        if (hasParamsConfig) {
            var currentDSRS = _this.dataStore.get(_state);
            var predicate = _this.paramsEqual(transTo.$$state(), triggerParams, undefined, true);
            var updatedDSRS = currentDSRS.filter(predicate).concat(recordedDSR);
            _this.dataStore.set(_state, updatedDSRS);
        }
        else {
            _this.dataStore.set(_state, [recordedDSR]);
        }
    });
};

the problem is at following line:
var predicate = _this.paramsEqual(transTo.$$state(), triggerParams, undefined, true);

insted of passing undefined as 3rd param of paramsEqual we should pass this.getConfig(state).params

Shall I forward a pull request in order to have it fixed???

Many thanks everybody.

DavideCordella and others added 2 commits May 17, 2019 09:01
DSR using params subset redirecting to the default state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants