@salla.sa/twilight-components 2.12.8 → 2.12.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/cjs/salla-add-product-button_40.cjs.entry.js +19 -8
  2. package/dist/cjs/salla-add-product-button_40.cjs.entry.js.map +1 -1
  3. package/dist/cjs/salla-product-options.cjs.entry.js +2 -1
  4. package/dist/cjs/salla-product-options.cjs.entry.js.map +1 -1
  5. package/dist/collection/components/salla-product-options/salla-product-options.js +2 -1
  6. package/dist/collection/components/salla-product-options/salla-product-options.js.map +1 -1
  7. package/dist/collection/components/salla-user-menu/salla-user-menu.js +19 -8
  8. package/dist/collection/components/salla-user-menu/salla-user-menu.js.map +1 -1
  9. package/dist/components/salla-product-options.js +2 -1
  10. package/dist/components/salla-product-options.js.map +1 -1
  11. package/dist/components/salla-user-menu.js +19 -8
  12. package/dist/components/salla-user-menu.js.map +1 -1
  13. package/dist/esm/salla-add-product-button_40.entry.js +19 -8
  14. package/dist/esm/salla-add-product-button_40.entry.js.map +1 -1
  15. package/dist/esm/salla-product-options.entry.js +2 -1
  16. package/dist/esm/salla-product-options.entry.js.map +1 -1
  17. package/dist/esm-es5/salla-add-product-button_40.entry.js +1 -1
  18. package/dist/esm-es5/salla-add-product-button_40.entry.js.map +1 -1
  19. package/dist/esm-es5/salla-product-options.entry.js +1 -1
  20. package/dist/esm-es5/salla-product-options.entry.js.map +1 -1
  21. package/dist/twilight/p-03cfdef7.system.js +1 -1
  22. package/dist/twilight/{p-d511f5f7.entry.js → p-8ce4ca08.entry.js} +2 -2
  23. package/dist/twilight/p-8ce4ca08.entry.js.map +1 -0
  24. package/dist/twilight/{p-9a09ec73.system.entry.js → p-9d88d784.system.entry.js} +2 -2
  25. package/dist/twilight/p-9d88d784.system.entry.js.map +1 -0
  26. package/dist/twilight/{p-d5a1906c.entry.js → p-c50e7524.entry.js} +2 -2
  27. package/dist/twilight/p-c50e7524.entry.js.map +1 -0
  28. package/dist/twilight/{p-9c38bff9.system.entry.js → p-f8addbca.system.entry.js} +2 -2
  29. package/dist/twilight/p-f8addbca.system.entry.js.map +1 -0
  30. package/dist/twilight/twilight.esm.js +1 -1
  31. package/dist/types/components/salla-user-menu/salla-user-menu.d.ts +1 -0
  32. package/package.json +2 -2
  33. package/dist/twilight/p-9a09ec73.system.entry.js.map +0 -1
  34. package/dist/twilight/p-9c38bff9.system.entry.js.map +0 -1
  35. package/dist/twilight/p-d511f5f7.entry.js.map +0 -1
  36. package/dist/twilight/p-d5a1906c.entry.js.map +0 -1
@@ -27994,12 +27994,18 @@ const SallaUserMenu = class {
27994
27994
  * //todo:: cover two requests in customer pages
27995
27995
  * //todo:: make sure to run this only after token is set
27996
27996
  */
27997
- if (salla.url.is_page('customer.notifications')
27997
+ const shouldFetchProfile = !this.inline && (salla.url.is_page('customer.notifications')
27998
27998
  || salla.url.is_page('customer.orders.index.pending')
27999
27999
  || salla.url.is_page('customer.profile')
28000
- || ((Date.now() - (salla.storage.get('user.fetched_at') || 0)) / 1000 / 60) > 30) {
28000
+ || ((Date.now() - (salla.storage.get('user.fetched_at') || 0)) / 1000 / 60) > 30);
28001
+ if (shouldFetchProfile) {
28001
28002
  this.fetchFreshProfile();
28002
28003
  }
28004
+ else {
28005
+ salla.event.on('profile::info.fetched', res => {
28006
+ this.updateProfileState(res);
28007
+ });
28008
+ }
28003
28009
  });
28004
28010
  }
28005
28011
  fetchFreshProfile() {
@@ -28010,14 +28016,19 @@ const SallaUserMenu = class {
28010
28016
  }
28011
28017
  salla.profile.api.info()
28012
28018
  .then((res) => {
28013
- this.badges.pending_orders = salla.helpers.number(res.data.pending_orders || 0);
28014
- this.badges.notifications = salla.helpers.number(res.data.notifications || 0);
28015
- this.hasBadges = Number(res.data.pending_orders) > 0 || Number(res.data.notifications) > 0;
28016
- this.first_name = res.data.first_name;
28017
- this.last_name = res.data.last_name;
28018
- this.avatar = res.data.avatar || salla.url.cdn('images/avatar.png');
28019
+ this.updateProfileState(res);
28019
28020
  });
28020
28021
  }
28022
+ updateProfileState(res) {
28023
+ this.badges = {
28024
+ notifications: salla.helpers.number(res.data.notifications || 0),
28025
+ pending_orders: salla.helpers.number(res.data.pending_orders || 0)
28026
+ };
28027
+ this.hasBadges = Number(res.data.pending_orders) > 0 || Number(res.data.notifications) > 0;
28028
+ this.first_name = res.data.first_name;
28029
+ this.last_name = res.data.last_name;
28030
+ this.avatar = res.data.avatar || salla.url.cdn('images/avatar.png');
28031
+ }
28021
28032
  async open(e) {
28022
28033
  this.opened = !this.opened;
28023
28034
  e.stopPropagation();