"See more" for albums and singles in artist page

This commit is contained in:
Shiny Nematoda 2023-03-24 10:34:26 +00:00
parent 9dd4534f83
commit 3f5abe967b
7 changed files with 81 additions and 85 deletions

View file

@ -15,7 +15,6 @@ export const useResults = defineStore('results', () => {
function setItem(key, val) {
items.value[key] = val;
console.log(items.value);
}
function resetItems() {
@ -23,28 +22,22 @@ export const useResults = defineStore('results', () => {
album.value = undefined;
useArtist().reset();
for (let i in items.value) {
items.value[i] = undefined;
}
for (let i in items.value) items.value[i] = undefined;
}
async function getExplore() {
const json = await getJsonHyp('/explore');
console.log(json);
resetItems();
chartsId.value = json.chartsId;
console.log(chartsId.value, json.chartsId);
setItem('songs', { items: json.trending });
setItem('albums', { items: json.albums_and_singles });
}
async function getAlbum(e) {
console.log('Album: ', e);
const hash = new URLSearchParams(e.substring(e.indexOf('?'))).get('list'),
isAuth =
/[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}/.test(
@ -53,8 +46,6 @@ export const useResults = defineStore('results', () => {
path = '/playlists/' + hash,
json = isAuth ? await getJsonAuth(path) : await getJsonPiped(path);
console.log(json, json.relatedStreams);
resetItems();
album.value = e;
@ -102,10 +93,10 @@ export const useArtist = defineStore('artist', () => {
thumbnails: [],
});
const results = useResults();
function reset() {
for (let i in state) {
state[i] = undefined;
}
for (let i in state) state[i] = undefined;
}
function set(obj) {
@ -115,22 +106,17 @@ export const useArtist = defineStore('artist', () => {
}
async function getArtist(e) {
console.log(e);
e = e.replace('/channel/', '');
const json = await getJsonHyp('/channel/' + e),
results = useResults();
console.log(json);
const json = await getJsonHyp('/channel/' + e);
results.resetItems();
for (let i in json.items) {
results.setItem(i, { items: json.items[i] });
}
console.log(results.items);
for (let i in json.items)
results.setItem(i, {
items: json.items[i],
more: json.more[i] ? { ...json.more[i], ...{ id: e } } : null,
});
json.items = undefined;
json.hash = e;
@ -142,5 +128,20 @@ export const useArtist = defineStore('artist', () => {
useNav().state.page = 'home';
}
return { state, set, reset, getArtist };
async function getArtistNext(i, { id, params, click, visit }) {
if (!id || !params || !click || !visit) return;
const json = await getJsonHyp(
`/next/channel/${id}/${params}?ct=${click}&v=${visit}`,
);
results.resetItems();
reset();
results.setItem(i, {
items: json.items,
});
}
return { state, set, reset, getArtist, getArtistNext };
});