Skip to content

Commit

Permalink
WIP: improve loading and update message
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienMaille committed Oct 13, 2024
1 parent 04c96a7 commit 5ceea45
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions default-dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ var coverListener;
function registerCoverListener() {
const img = document.querySelector(".main-image-image.cover-art-image");
if (!img) return setTimeout(registerCoverListener, 250); // Check if image exists
if (!img.complete) return img.addEventListener("load", registerCoverListener); // Check if image is loaded
if (!img.complete) return setTimeout(registerCoverListener, 250); // Check if image is loaded
pickCoverColor(img);

if (coverListener != null) {
Expand Down Expand Up @@ -337,13 +337,17 @@ registerCoverListener();
})
.then((data) => {
if (data.tag_name > current) {
document.querySelector("#main-topBar-moon-button").classList.remove("main-topBar-buddyFeed");
document.querySelector("#main-topBar-moon-button").classList.add("main-actionButtons-button", "main-noConnection-isNotice");
const button = document.querySelector("#main-topBar-moon-button");
button.classList.remove("main-topBar-buddyFeed");
button.classList.add("main-actionButtons-button", "main-noConnection-isNotice");
let updateLink = document.createElement("a");
updateLink.setAttribute("title", `Changes: ${data.name}`);
updateLink.setAttribute("href", "https://github.com/JulienMaille/spicetify-dynamic-theme/releases/latest");
updateLink.innerHTML = `v${data.tag_name} available`;
document.querySelector("#main-topBar-moon-button").append(updateLink);
button.append(updateLink);
button._tippy.setProps({
allowHTML: true,
content: `Changes: ${data.name}`
});
}
})
.catch((err) => {
Expand Down

0 comments on commit 5ceea45

Please sign in to comment.