probleme favoris

This commit is contained in:
2025-04-01 13:29:11 +02:00
parent eabc11d2cc
commit f8e3034dcf
2 changed files with 15 additions and 3 deletions

View File

@@ -77,7 +77,6 @@
base: 'https://dwarves.iut-fbleau.fr/~felix-vi/SAE_riot/',
route: 'search',
authUser: null,
favoritesIds: [],
searchs: {
items: [],
pagination: [],

View File

@@ -15,7 +15,7 @@
<a onclick={() => removeFavoris(item.id)}>
<button><i class="fa-solid fa-star"></i></button>
</a>
<a href={"#/release-details/" + item.id}>
<a href={"#/release-details/" +(item.isMaster ? "master" : "release") + "/" + item.id}>
<h4>{item.title}</h4>
<img src={item.thumb} alt="cover" />
<div if={item.type !== 'artist'}>
@@ -48,11 +48,24 @@
items.push(release);
}
this.state.favorites.items = items;
const masterPromises = items.map(item => isMaster(item.id, item.master_id));
const masterResults = await Promise.all(masterPromises);
const enrichedItems = result.results.map((item, index) => ({
...item,
isMaster: masterResults[index]
}));
this.state.favorites.items = enrichedItems;
this.state.loading = false;
console.log(this.state)
this.update();
},
ismaster(id , master_id){
return id === master_id;
},
async removeFavoris(id) {
await window.removeFavorite(id);
this.state.favorites.items = this.state.favorites.items.filter(item => item.id !== id);