Don't show more then three announcement popups (because it can be annoying for new users)

This commit is contained in:
naskya 2023-07-08 20:31:18 +00:00
parent d8a94fc707
commit 20fbb4f57e
No known key found for this signature in database
GPG Key ID: 164DFF24E2D40139

View File

@ -273,19 +273,26 @@ function checkForSplash() {
} }
if ($i) { if ($i) {
api("announcements", { withUnreads: true }) api("announcements", { withUnreads: true, limit: 10 })
.then((announcements) => { .then((announcements) => {
announcements.forEach((announcement) => { const unreadAnnouncements = announcements.filter((item) => {
if (announcement.showPopup && announcement.isRead === false) return !item.isRead;
});
if (unreadAnnouncements.length > 3) {
// TODO: navigate to the announcements page when there are too many unreads
} else {
unreadAnnouncements.forEach((item) => {
if (item.showPopup)
popup( popup(
defineAsyncComponent( defineAsyncComponent(
() => import("@/components/MkAnnouncement.vue"), () => import("@/components/MkAnnouncement.vue"),
), ),
{ announcement: announcement }, { announcement: item },
{}, {},
"closed", "closed",
); );
}); });
}
}) })
.catch((err) => console.log(err)); .catch((err) => console.log(err));
} }