1
0
mirror of https://github.com/beestat/app.git synced 2025-06-01 20:56:44 -04:00

Fixed #295 - If there are no announcements, clicking the announcements button breaks

This commit is contained in:
Jon Ziebell 2021-01-27 21:01:10 -05:00
parent 8087410436
commit 2155015bb6

View File

@ -13,6 +13,10 @@ beestat.extend(beestat.component.modal.announcements, beestat.component.modal);
*/ */
beestat.component.modal.announcements.prototype.decorate_contents_ = function(parent) { beestat.component.modal.announcements.prototype.decorate_contents_ = function(parent) {
var announcements = $.values(beestat.cache.announcement).reverse(); var announcements = $.values(beestat.cache.announcement).reverse();
if (announcements.length === 0) {
parent.appendChild($.createElement('p').innerText('No recent announcements! :)'));
} else {
announcements.forEach(function(announcement) { announcements.forEach(function(announcement) {
parent.appendChild($.createElement('div').style({ parent.appendChild($.createElement('div').style({
'border-bottom': '1px solid #eee', 'border-bottom': '1px solid #eee',
@ -38,6 +42,7 @@ beestat.component.modal.announcements.prototype.decorate_contents_ = function(pa
'last_read_announcement_id', 'last_read_announcement_id',
announcements[0].announcement_id announcements[0].announcement_id
); );
}
}; };
/** /**