chore: Prettified Code

[ci skip]
This commit is contained in:
booploops 2022-09-30 05:05:30 +00:00 committed by cider-chore[bot]
parent c5d86a9a0f
commit bc939f55dc
2 changed files with 40 additions and 38 deletions

View file

@ -290,7 +290,7 @@ const app = new Vue({
},
methods: {
setWindowHash(route = "") {
this.setPagePos()
this.setPagePos();
window.location.hash = `#${route}`;
},
monitorMusickit() {
@ -600,8 +600,8 @@ const app = new Vue({
}
},
navigateBack() {
this.setPagePos()
this.resumePagePos()
this.setPagePos();
this.resumePagePos();
this.chrome.desiredPageTransition = "wpfade_transform_backwards";
return new Promise((resolve, reject) => {
history.back();
@ -611,8 +611,8 @@ const app = new Vue({
});
},
goToGrouping(url = "https://music.apple.com/WebObjects/MZStore.woa/wa/viewGrouping?cc=us&id=34") {
this.setPagePos()
this.resumePagePos()
this.setPagePos();
this.resumePagePos();
if (url.includes("viewTop")) {
window.location.hash = `#charts/top`;
} else {
@ -638,8 +638,8 @@ const app = new Vue({
}
},
navigateForward() {
this.setPagePos()
this.resumePagePos()
this.setPagePos();
this.resumePagePos();
history.forward();
},
resetState() {
@ -2089,11 +2089,13 @@ const app = new Vue({
getPagePos(href = "") {
let state = this.$store.state.pageState.scrollPos.pos.find((page) => {
return page.href === href;
})
return state ?? {
});
return (
state ?? {
page: href,
position: 0
position: 0,
}
);
},
appRoute(route) {
if (route == "" || route == "#" || route == "/") {
@ -2112,7 +2114,7 @@ const app = new Vue({
if (route.indexOf("/") == -1) {
this.page = route;
window.location.hash = this.page;
this.resumePagePos()
this.resumePagePos();
// if (this.page == "settings") {
// this.version
// }
@ -2136,22 +2138,22 @@ const app = new Vue({
});
},
resumePagePos() {
setTimeout(()=>{
$("#app-content").scrollTop(app.getPagePos(window.location.hash).position)
}, 100)
setTimeout(() => {
$("#app-content").scrollTop(app.getPagePos(window.location.hash).position);
}, 100);
},
setPagePos() {
console.debug({
href: window.location.hash,
position: $("#app-content").scrollTop()
})
position: $("#app-content").scrollTop(),
});
this.$store.commit("setPagePos", {
href: window.location.hash,
position: $("#app-content").scrollTop()
})
position: $("#app-content").scrollTop(),
});
},
routeView(item) {
this.setPagePos()
this.setPagePos();
let kind = item.attributes?.playParams ? item.attributes?.playParams?.kind ?? item.type ?? "" : item.type ?? "";
let id = item.attributes?.playParams ? item.attributes?.playParams?.id ?? item.id ?? "" : item.id ?? "";
let isLibrary = item.attributes?.playParams ? item.attributes?.playParams?.isLibrary ?? false : false;
@ -2228,7 +2230,7 @@ const app = new Vue({
window.location.hash = `${kind}/${id}`;
// document.querySelector("#app-content").scrollTop = 0;
});
this.resumePagePos()
this.resumePagePos();
} else if (kind.toString().includes("artist")) {
app.getArtistInfo(id, isLibrary);
window.location.hash = `${kind}/${id}${isLibrary ? "/" + isLibrary : ""}`;
@ -2247,7 +2249,7 @@ const app = new Vue({
});
window.location.hash = `${kind}/${id}`;
document.querySelector("#app-content").scrollTop = 0;
this.resumePagePos()
this.resumePagePos();
} else if (kind.toString().includes("social-profiles")) {
app.page = kind + "_" + id;
app.mk.api.v3
@ -2288,7 +2290,7 @@ const app = new Vue({
app.page = kind;
window.location.hash = `${kind}/${id}${isLibrary ? "/" + isLibrary : ""}`;
}
this.resumePagePos()
this.resumePagePos();
// app.getTypeFromID((kind), (id), (isLibrary), params);
} else if (kind.toString().includes("song")) {
const albumUrl = new Promise(async (resolve, reject) => {

View file

@ -20,8 +20,8 @@ const store = new Vuex.Store({
},
scrollPos: {
limit: 10,
pos: []
}
pos: [],
},
},
artwork: {
playerLCD: "",
@ -39,24 +39,24 @@ const store = new Vuex.Store({
setPagePos(state, pageState = {}) {
let cached = state.pageState.scrollPos.pos.find((page) => {
return page.href === pageState.href;
})
if(cached) {
});
if (cached) {
state.pageState.scrollPos.pos.find((page) => {
if(page.href === pageState.href) {
page.position = pageState.position
if (page.href === pageState.href) {
page.position = pageState.position;
}
})
return
});
return;
}
state.pageState.scrollPos.pos.push({
"href": pageState.href,
"position": pageState.position
})
href: pageState.href,
position: pageState.position,
});
if (state.pageState.scrollPos.pos.length > state.pageState.scrollPos.limit) {
pages.value.shift()
}
return
pages.value.shift();
}
return;
},
},
});