diff --git a/components/app.riot b/components/app.riot index 24b425e..8b18034 100644 --- a/components/app.riot +++ b/components/app.riot @@ -77,7 +77,6 @@ base: 'https://dwarves.iut-fbleau.fr/~felix-vi/SAE_riot/', route: 'search', authUser: null, - favoritesIds: [], searchs: { items: [], pagination: [], diff --git a/components/favorites.riot b/components/favorites.riot index 8c96b8e..580673d 100644 --- a/components/favorites.riot +++ b/components/favorites.riot @@ -15,7 +15,7 @@ removeFavoris(item.id)}> - +

{item.title}

cover
@@ -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);