diff --git a/components/app.riot b/components/app.riot
index c1a1987..30184de 100644
--- a/components/app.riot
+++ b/components/app.riot
@@ -52,6 +52,7 @@
+
@@ -104,7 +105,7 @@
this.searchs.pagination = result.pagination;
this.searchs.query = query;
this.searchs.type = type;
-
+ console.log()
this.update();
},
@@ -141,6 +142,18 @@
Logout(){
window.logout()
this.update();
+ },
+
+ async MainReleaseDetails(item) {
+ const res = await fetch(item.resource_url);
+ const json = await res.json();
+
+ const mainUrl = json.main_release_url;
+
+ const res2 = await fetch(mainUrl);
+ const releaseData = await res2.json();
+
+ window.location.hash = `#/release-details/release/${releaseData.id}`;
}
}
diff --git a/components/favorites.riot b/components/favorites.riot
index 8ecf2ad..e25ab5d 100644
--- a/components/favorites.riot
+++ b/components/favorites.riot
@@ -26,6 +26,8 @@
+
+
@@ -60,7 +62,6 @@
this.state.favorites.items = items;
this.state.loading = false;
- console.log(this.state)
this.update();
},
@@ -68,6 +69,19 @@
await window.removeFavorite(id, type);
this.state.favorites.items = this.state.favorites.items.filter(item => item.id !== id);
this.update();
+ },
+
+ async MainReleaseDetails(item) {
+ const res = await fetch(item.resource_url);
+ const json = await res.json();
+
+ const mainUrl = json.main_release_url;
+
+ const res2 = await fetch(mainUrl);
+ const releaseData = await res2.json();
+
+ console.log(releaseData);
+ window.location.hash = `#/release-details/release/${releaseData.id}`;
}
}
diff --git a/components/release-details.riot b/components/release-details.riot
index 868e4a4..c4f9d70 100644
--- a/components/release-details.riot
+++ b/components/release-details.riot
@@ -6,13 +6,16 @@
{state.release.year}
- {state.release.name}
+ {state.release.artists[0].name}
-
Track list
+
Track list
+
+
{state.release.message}
+
-
{track.position} - {track.title} - {track.duration}
@@ -24,18 +27,22 @@
+
{state.release.name}
+ Biographie
{state.release.profile}
+ Pas de profil
Crédits :
-
+
+
@@ -48,23 +55,38 @@
resource: []
},
- async onMounted() {
- const id = this.props.Id
- if(this.props.Type === "release"){
- this.state.release = await window.getReleaseDetails(id);
+ previousId: null,
+ previousType: "",
- // Récupérer les extra-artists depuis leur URL
- const response = await fetch(this.state.release.resource_url);
- this.state.resource = await response.json();
+ async onMounted() {
+ await this.loadData()
+ },
+
+ async onBeforeUpdate() {
+ if (this.props.Id !== this.previousId || this.props.Type !== this.previousType) {
+ await this.loadData()
}
- else if (this.props.Type === "master"){
- this.state.release = await window.getMasterDetails(id)
+ },
+
+ async loadData() {
+ this.previousId = this.props.Id
+ this.previousType = this.props.Type
+
+ if (this.props.Type === "release") {
+ this.state.release = await window.getReleaseDetails(this.props.Id)
+ const response = await fetch(this.state.release.resource_url)
+ this.state.resource = await response.json()
+ } else if (this.props.Type === "master") {
+ this.state.release = await window.getMasterDetails(this.props.Id)
+ } else if (this.props.Type === "artist") {
+ this.state.release = await window.getArtistDetails(this.props.Id)
}
- else{
- this.state.release = await window.getArtistDetails(id)
- }
- console.log(this.state.release)
this.update()
+ },
+
+ goToArtist(e) {
+ const url = e.target.value;
+ if (url) window.location.hash = url;
}
}
@@ -188,5 +210,6 @@
.credits a:hover {
text-decoration: underline;
}
+
\ No newline at end of file
diff --git a/index.html b/index.html
index ecaf430..d09bd59 100644
--- a/index.html
+++ b/index.html
@@ -5,8 +5,8 @@
Music App RiotJS
-
-
+
+