-
Notifications
You must be signed in to change notification settings - Fork 520
Description
Describe the bug
When a theme is configured for a given handle, object pages within this theme will (inconsistently) send out two "viewevents" POST requests instead of just one, upon page visit.
To Reproduce
Steps to reproduce the behaviour:
- Configure a theme for an object handle (see example configuration below)
- Visit the page of an item that falls under the object handle (e.g. the handle points towards a parent community of said item)
- In the Network tab, you should see two "viewevents" POST requests (filter by
method:POSTto notice easier). This is not consistent, but to my experience, happens most of the time. It depends a bit on how fast the initial page load is (see more info below for the cause).
Example configuration:
themes:
- name: custom
extends: dspace
handle: 123456789/1
- name: dspace
Tip: You can use the configuration above, connected to the demo instance and visiting the Publications community and/or any of its collections or items.
Expected behaviour
Only one "viewevents" POST request should be sent per page view.
Cause
The reason it's sending out two requests instead of one, is because requests are sent when the ViewTrackerComponent is loaded for an object page, but the theme configuration causes a reload of the contents, causing the component to be recreated a second time.
Possible fixes
I see two solutions, with the second option being less desired than the first, but might be a good fallback:
- Prevent DSO page contents from loading before the theme is fully resolved. This would however mean longer loading screens, but in turn no flashing reload.
- Prevent the
ViewTrackerComponentsending a request when it detects it's not on the correct theme yet. This is possible by querying theThemeServiceto check what the currently active theme is and comparing that against whateverThemeresolves from theDSpaceObject.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status