probleme
This commit is contained in:
@@ -40,7 +40,8 @@
|
||||
<div class="results-grid">
|
||||
<div class="card" each="{item in searchs.items}">
|
||||
<!-- Afficher l'étoile avec la musique immédiatement -->
|
||||
<a if={authUser && this.searchs.type !== "artist"} onclick={() => item.isFavorite ? this.removeFavoris(item.id) : this.addFavoris(item.id)}>
|
||||
{console.log(item.isFavorite)}
|
||||
<a if={authUser && this.searchs.type !== "artist"} onclick={() => item.isFavorite ? this.removeFavoris(item.id, item.type) : this.addFavoris(item.id, item.type)}>
|
||||
<button><i class={item.isFavorite ? "fa-solid fa-star" : "fa-regular fa-star"}></i></button>
|
||||
</a>
|
||||
<a href={ "#/release-details/" + item.type + "/" + item.id}>
|
||||
@@ -93,7 +94,7 @@
|
||||
const result = await window.discogsearch(query, type, page);
|
||||
console.log(result);
|
||||
|
||||
const favoritePromises = result.results.map(item => window.isFavorite(item.id));
|
||||
const favoritePromises = result.results.map(item => window.isFavorite(item.id, item.type));
|
||||
const favoritesResults = await Promise.all(favoritePromises);
|
||||
|
||||
const enrichedItems = result.results.map((item, index) => ({
|
||||
@@ -123,22 +124,19 @@
|
||||
this.update();
|
||||
},
|
||||
|
||||
addFavoris(id) {
|
||||
window.favorite(id)
|
||||
addFavoris(id, type) {
|
||||
window.favorite(id, type);
|
||||
this.searchs.items = this.searchs.items.map(item =>
|
||||
item.id === id ? { ...item, isFavorite: true } : item
|
||||
);
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
async removeFavoris(id) {
|
||||
await window.removeFavorite(id);
|
||||
|
||||
async removeFavoris(id, type) {
|
||||
await window.removeFavorite(id, type);
|
||||
this.searchs.items = this.searchs.items.map(item =>
|
||||
item.id === id ? { ...item, isFavorite: false } : item
|
||||
);
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user