| 1 |
import { Interaction } from '@web/public/interaction'; |
| 2 |
import { registry } from '@web/core/registry'; |
| 3 |
import { rpc } from '@web/core/network/rpc'; |
| 4 |
import wishlistUtils from '@website_sale_wishlist/js/website_sale_wishlist_utils'; |
| 5 |
|
| 6 |
export class WishlistNavbar extends Interaction { |
| 7 |
static selector = '.o_wsale_my_wish'; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
async willStart() { |
| 13 |
const wishCount = parseInt(this.el.querySelector('.my_wish_quantity')?.textContent); |
| 14 |
if (wishlistUtils.getWishlistProductIds().length !== wishCount) { |
| 15 |
wishlistUtils.setWishlistProductIds( |
| 16 |
await this.waitFor(rpc('/shop/wishlist/get_product_ids')) |
| 17 |
); |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
start() { |
| 25 |
wishlistUtils.updateWishlistNavBar(); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
registry |
| 30 |
.category('public.interactions') |
| 31 |
.add('website_sale_wishlist.wishlist_navbar', WishlistNavbar); |