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

Fixed multiple call on language change. #112

Merged
merged 3 commits into from
Mar 11, 2019
Merged

Fixed multiple call on language change. #112

merged 3 commits into from
Mar 11, 2019

Conversation

NayanKhedkar
Copy link
Member

Refer:Issue

Copy link
Member

@danielstorey danielstorey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will prevent the rendering of multiple progress bars, but I'm not sure it will take into account the new settings when the language is changed.

@moloko
Copy link
Contributor

moloko commented Mar 5, 2019

I had a thought that maybe we could get PageLevelProgressNavigationView to do this.remove on app:languageChange - but it doesn't quite seem to be doing the job. I haven't exactly spent a lot of time on it (and now have to do something else) but still feel it might be a valid solution?

stupid idea! never going to work...

@moloko
Copy link
Contributor

moloko commented Mar 5, 2019

OK, I think changing the initialize function adapt-contrib-pageLevelProgress.js to this:

Adapt.on({
    'app:dataReady': this.onDataReady.bind(this),
    'app:languageChanged': function() {
        this.stopListening();
    }.bind(this)
});

works OK...?

If, like me, you look at that code and are tempted to tidy it up, be aware that if you do either this:

Adapt.on({
    'app:dataReady': this.onDataReady,
    'app:languageChanged': this.stopListening
}, this);

Then both those event handlers get removed by this.stopListening as well.

This works:

Adapt.on({
    'app:dataReady': this.onDataReady.bind(this),
    'app:languageChanged': this.stopListening.bind(this)
});

@NayanKhedkar
Copy link
Member Author

@moloko I am also wondering.
'app:languageChanged': this.stopListening.bind(this)

'app:languageChanged': function() { this.stopListening(); }.bind(this)

both these two line doing same thing.May be the mess with scope.

should I go with.
Adapt.on({
    'app:dataReady': this.onDataReady.bind(this),
    'app:languageChanged': function() {
        this.stopListening();
    }.bind(this)
}) ;

@moloko
Copy link
Contributor

moloko commented Mar 6, 2019

both these two line doing same thing

Well, you'd think so wouldn't you? but when I tried this.stopListening.bind(this) I'm pretty sure that it removed ALL the listeners! But then it was getting pretty late at that point so I may have made a simple mistake like forgetting to reload properly or doing so too quickly so the dev process hadn't finished... you know the sort of thing I'm sure ;-) So please feel free to give this a try for yourself and see what works and then I will re-test once you're happy.

@NayanKhedkar
Copy link
Member Author

NayanKhedkar commented Mar 7, 2019

Adapt.on({
    'app:dataReady': this.onDataReady.bind(this),
    'app:languageChanged': function() {
        this.stopListening();
    }.bind(this)
});

Worked fine for me.

@moloko moloko merged commit dcd8f58 into master Mar 11, 2019
@moloko moloko deleted the issue/#2368 branch March 11, 2019 12:21
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.

None yet

4 participants