From 269f010b13625a05d32694592b13e4e5c3596fff Mon Sep 17 00:00:00 2001 From: vapormusic Date: Wed, 9 Feb 2022 21:30:04 +0700 Subject: [PATCH] fix searchtab categories --- src/renderer/views/pages/search.ejs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/renderer/views/pages/search.ejs b/src/renderer/views/pages/search.ejs index 70ed1e74..60974726 100644 --- a/src/renderer/views/pages/search.ejs +++ b/src/renderer/views/pages/search.ejs @@ -93,7 +93,7 @@ + v-for="item of getFlattenedCategories()"> @@ -123,9 +123,22 @@ if (this.categoriesView != [] && this.categoriesView.length > 0) { this.categoriesReady = true; return await true; } else { let response = await this.app.mk.api.v3.music(`/v1/recommendations/${this.app.mk.storefrontId}?timezone=${encodeURIComponent(this.app.formatTimezoneOffset())}&name=search-landing&platform=web&extend=editorialArtwork&art%5Burl%5D=f%2Cc&types=editorial-items%2Capple-curators%2Cactivities`); this.categoriesView = response.data.data; + console.log(this.categoriesView) this.categoriesReady = true; return await true; } + }, + getFlattenedCategories() { + let flattened = []; + for (let i = 0; i < this.categoriesView.length; i++) { + if (this.categoriesView[i].relationships && this.categoriesView[i].relationships.contents && this.categoriesView[i].relationships.contents.data) { + for (let j = 0; j < this.categoriesView[i].relationships.contents.data.length; j++) { + if (this.categoriesView[i].relationships.contents.data[j].type != 'editorial-items') + flattened.push(this.categoriesView[i].relationships.contents.data[j]) + } + } + } + return flattened; } } })