probleme favoris
This commit is contained in:
@@ -77,7 +77,6 @@
|
|||||||
base: 'https://dwarves.iut-fbleau.fr/~felix-vi/SAE_riot/',
|
base: 'https://dwarves.iut-fbleau.fr/~felix-vi/SAE_riot/',
|
||||||
route: 'search',
|
route: 'search',
|
||||||
authUser: null,
|
authUser: null,
|
||||||
favoritesIds: [],
|
|
||||||
searchs: {
|
searchs: {
|
||||||
items: [],
|
items: [],
|
||||||
pagination: [],
|
pagination: [],
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<a onclick={() => removeFavoris(item.id)}>
|
<a onclick={() => removeFavoris(item.id)}>
|
||||||
<button><i class="fa-solid fa-star"></i></button>
|
<button><i class="fa-solid fa-star"></i></button>
|
||||||
</a>
|
</a>
|
||||||
<a href={"#/release-details/" + item.id}>
|
<a href={"#/release-details/" +(item.isMaster ? "master" : "release") + "/" + item.id}>
|
||||||
<h4>{item.title}</h4>
|
<h4>{item.title}</h4>
|
||||||
<img src={item.thumb} alt="cover" />
|
<img src={item.thumb} alt="cover" />
|
||||||
<div if={item.type !== 'artist'}>
|
<div if={item.type !== 'artist'}>
|
||||||
@@ -48,11 +48,24 @@
|
|||||||
items.push(release);
|
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;
|
this.state.loading = false;
|
||||||
|
console.log(this.state)
|
||||||
this.update();
|
this.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ismaster(id , master_id){
|
||||||
|
return id === master_id;
|
||||||
|
},
|
||||||
|
|
||||||
async removeFavoris(id) {
|
async removeFavoris(id) {
|
||||||
await window.removeFavorite(id);
|
await window.removeFavorite(id);
|
||||||
this.state.favorites.items = this.state.favorites.items.filter(item => item.id !== id);
|
this.state.favorites.items = this.state.favorites.items.filter(item => item.id !== id);
|
||||||
|
|||||||
Reference in New Issue
Block a user