fix: don't crash for guests @julianlam or if component is misisng

This commit is contained in:
Barış Soner Uşaklı 2023-02-03 19:44:01 -05:00
parent c4ae8d2ae7
commit 11685db7b1

View file

@ -234,8 +234,15 @@ $(document).ready(function () {
}

function fixPlaceholders() {
if (!config.loggedIn) {
return;
}
['notifications', 'chat'].forEach((type) => {
const count = parseInt(document.querySelector(`[component="${type}/count"]`).innerText, 10);
const countEl = document.querySelector(`[component="${type}/count"]`);
if (!countEl) {
return;
}
const count = parseInt(countEl.innerText, 10);
if (count > 1) {
const listEls = document.querySelectorAll(`[component="${type}/list"]`);
listEls.forEach((listEl) => {