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

View file

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