[DURACOM-353] fix orejime callbacks#4225
Conversation
tdonohue
left a comment
There was a problem hiding this comment.
@AndreaBarbasso : Thanks for this PR. Overall, it is working well. I can verify that, after logging in, if I save the Cookie Settings, I'll see a PATCH request to change those settings in my account. If I then logout & login again, those same Cookie settings are restored.
However, I did find a small bug. If you run this in Production mode (npm run build:prod && npm run serve:ssr), then you'll see a TypeError appear on the homepage if you are not logged in:
ERROR TypeError: Cannot read properties of undefined (reading 'uuid')
at d.updateSettingsForUsers (main.05f4e55b85d89082.js:1:1789348)
at main.05f4e55b85d89082.js:1:1787004
at F (main.05f4e55b85d89082.js:1:2220475)
at X (main.05f4e55b85d89082.js:1:2220708)
at W (main.05f4e55b85d89082.js:1:2220593)
at bt.<computed> (polyfills.de6e35a366b9582f.js:1:12038)
at Z.invokeTask (polyfills.de6e35a366b9582f.js:1:21035)
at Object.onInvokeTask (main.05f4e55b85d89082.js:1:2570651)
at Z.invokeTask (polyfills.de6e35a366b9582f.js:1:20954)
at wt.runTask (polyfills.de6e35a366b9582f.js:1:16205)
To Reproduce this bug:
- Install this PR in production mode
- Open your browser's DevTools & watch the Console
- Access the homepage anonymously. The TypeError will appear because no one is logged in.
Once that minor bug is fixed, I'm +1 this PR. Looks good!
|
@AndreaBarbasso : If you could find time to fix the |
|
@tdonohue, sorry for leaving this hanging, but a one-two combo of sick leave and Italian bank holidays happened! I pushed a fix that resolves the error you encountered. Thanks for finding it! |
tdonohue
left a comment
There was a problem hiding this comment.
👍 Thanks @AndreaBarbasso ! This is now working perfectly. Code looks good too
References
Description
Since orejime does not have a "global" callback property, we need to apply the method that updates user preferences to each app in orejime's config, and of course we need to call any custom callback already there for each app.
Instructions for Reviewers
List of changes in this PR:
applyUpdateSettingsCallbackToAppsmethod. This method changes thecallbackproperty of each app by calling the method that updates the saved user settings, and then calls anycallbackfunction set to that app in config.To test this PR, you need to add a non-mandatory cookie to the orejime configuration and then enable/disable that cookie. Changes should be persisted on the REST side, and any original callback should be called.
Checklist
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.