fix issue with status indactor
Some checks failed
Code quality checks / biome (push) Failing after 9s
Some checks failed
Code quality checks / biome (push) Failing after 9s
This commit is contained in:
parent
7d0c65ff8c
commit
397dc422c5
1 changed files with 33 additions and 15 deletions
|
@ -419,25 +419,43 @@ async function updatePresence(data) {
|
||||||
status = data.discord_status;
|
status = data.discord_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
let updatedStatusIndicator = avatarWrapper.querySelector(".status-indicator");
|
for (const el of avatarWrapper.querySelectorAll(".platform-icon")) {
|
||||||
const updatedMobileIcon = avatarWrapper.querySelector(
|
const platformType = ["mobile-only", "desktop-only", "web-only"].find(type => el.classList.contains(type));
|
||||||
".platform-icon.mobile-only",
|
|
||||||
);
|
|
||||||
|
|
||||||
if (platform.mobile && !updatedMobileIcon) {
|
if (!platformType) continue;
|
||||||
avatarWrapper.innerHTML += `
|
|
||||||
<svg class="platform-icon mobile-only ${status}" viewBox="0 0 1000 1500" fill="#43a25a" aria-label="Mobile" width="17" height="17">
|
const active =
|
||||||
<path d="M 187 0 L 813 0 C 916.277 0 1000 83.723 1000 187 L 1000 1313 C 1000 1416.277 916.277 1500 813 1500 L 187 1500 C 83.723 1500 0 1416.277 0 1313 L 0 187 C 0 83.723 83.723 0 187 0 Z M 125 1000 L 875 1000 L 875 250 L 125 250 Z M 500 1125 C 430.964 1125 375 1180.964 375 1250 C 375 1319.036 430.964 1375 500 1375 C 569.036 1375 625 1319.036 625 1250 C 625 1180.964 569.036 1125 500 1125 Z"/>
|
(platformType === "mobile-only" && platform.mobile) ||
|
||||||
</svg>
|
(platformType === "desktop-only" && platform.desktop) ||
|
||||||
`;
|
(platformType === "web-only" && platform.web);
|
||||||
} else if (!platform.mobile && updatedMobileIcon) {
|
|
||||||
updatedMobileIcon.remove();
|
if (!active) {
|
||||||
avatarWrapper.innerHTML += `<div class="status-indicator ${status}"></div>`;
|
el.remove();
|
||||||
|
} else {
|
||||||
|
el.setAttribute("class", `platform-icon ${platformType} ${status}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updatedStatusIndicator = avatarWrapper.querySelector(".status-indicator");
|
if (platform.mobile && !avatarWrapper.querySelector(".platform-icon.mobile-only")) {
|
||||||
|
const mobileIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||||
|
mobileIcon.setAttribute("class", `platform-icon mobile-only ${status}`);
|
||||||
|
mobileIcon.setAttribute("viewBox", "0 0 1000 1500");
|
||||||
|
mobileIcon.setAttribute("fill", "#43a25a");
|
||||||
|
mobileIcon.setAttribute("aria-label", "Mobile");
|
||||||
|
mobileIcon.setAttribute("width", "17");
|
||||||
|
mobileIcon.setAttribute("height", "17");
|
||||||
|
mobileIcon.innerHTML = `
|
||||||
|
<path d="M 187 0 L 813 0 C 916.277 0 1000 83.723 1000 187 L 1000 1313 C 1000 1416.277 916.277 1500 813 1500 L 187 1500 C 83.723 1500 0 1416.277 0 1313 L 0 187 C 0 83.723 83.723 0 187 0 Z M 125 1000 L 875 1000 L 875 250 L 125 250 Z M 500 1125 C 430.964 1125 375 1180.964 375 1250 C 375 1319.036 430.964 1375 500 1375 C 569.036 1375 625 1319.036 625 1250 C 625 1180.964 569.036 1125 500 1125 Z"/>
|
||||||
|
`;
|
||||||
|
avatarWrapper.appendChild(mobileIcon);
|
||||||
|
}
|
||||||
|
|
||||||
if (updatedStatusIndicator) {
|
const updatedStatusIndicator = avatarWrapper.querySelector(".status-indicator");
|
||||||
|
if (!updatedStatusIndicator) {
|
||||||
|
const statusDiv = document.createElement("div");
|
||||||
|
statusDiv.className = `status-indicator ${status}`;
|
||||||
|
avatarWrapper.appendChild(statusDiv);
|
||||||
|
} else {
|
||||||
updatedStatusIndicator.className = `status-indicator ${status}`;
|
updatedStatusIndicator.className = `status-indicator ${status}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue