Skip to content
This repository was archived by the owner on Sep 20, 2020. It is now read-only.
This repository was archived by the owner on Sep 20, 2020. It is now read-only.

DSR using params subset redirecting to the default state #382

Description

@DavideCordella

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]);
            }
        });
    };`

triggerParams match targetParams and that's not correct when using a subset of the parameters of the target state.

Can you advise?

Many thanks everybody.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions