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

Avoid loading widget urls twice #18665

Closed
wants to merge 2 commits into from
Closed

Avoid loading widget urls twice #18665

wants to merge 2 commits into from

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Jan 20, 2022

Description:

@diosmosis It seems that watching the parameters is also triggered after the component was mounted, currently causing the widget url to be loaded twice.
Tried avoiding that by checking if the parameters actually changed. Locally that worked well. Or is there a better solution for that?

fixes #18662

Review

@sgiehl sgiehl added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Jan 20, 2022
@sgiehl sgiehl added this to the 4.7.0 milestone Jan 20, 2022
@sgiehl sgiehl requested a review from diosmosis January 20, 2022 10:58
widgetParams(parameters: QueryParameters) {
if (parameters) {
widgetParams(parameters: QueryParameters, oldParameters: QueryParameters) {
if (parameters && JSON.stringify(parameters) !== JSON.stringify(oldParameters)) {
Copy link
Member

@diosmosis diosmosis Jan 20, 2022

Choose a reason for hiding this comment

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

If this is also executed on mount, the mounted() code could just be removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Wasn't sure if that is always the case or some kind of race condition because of the angularjs <> vue mixup maybe.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, I'll investigate as I don't understand exactly what's happening here.

Copy link
Member

Choose a reason for hiding this comment

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

I couldn't reproduce this, tried in the dashboard and in a report page. It's possible the parameters object is set to a new object that has the exact same value, maybe when loading the same page? If it's something you could reproduce it would be good to figure out where JSON.stringify(oldParameters) === JSON.stringify(newParameters) gets triggered (via debugger; for instance). Not doing anything in this case might result in nothing happening when the user tries to reload the current page (ie, user is on Visitors Overview, then clicks Visitors Overview to reload the widgets).

Copy link
Member Author

Choose a reason for hiding this comment

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

@diosmosis It only happens on the admin page and only with disabled developer mode (merged assets).

Copy link
Member

Choose a reason for hiding this comment

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

@sgiehl fixed it here: #18672

It happens w/ developer mode enabled too.

@diosmosis diosmosis closed this Jan 22, 2022
@sgiehl sgiehl deleted the m-18662 branch April 5, 2023 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Admin home issues requests and then cancels them again
2 participants