mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-11 07:25:42 -04:00
don't advance announcements if the dialog already opened
This commit is contained in:
@@ -85,20 +85,15 @@ const dialog = defineModel<boolean>({ default: false });
|
|||||||
const { newAnnouncements, allAnnouncements, setLastRead } = useAnnouncements();
|
const { newAnnouncements, allAnnouncements, setLastRead } = useAnnouncements();
|
||||||
|
|
||||||
const currentAnnouncement = shallowRef<Announcement | undefined>();
|
const currentAnnouncement = shallowRef<Announcement | undefined>();
|
||||||
watch(
|
watch(dialog, () => {
|
||||||
dialog,
|
if (!dialog.value || currentAnnouncement.value) {
|
||||||
() => {
|
return;
|
||||||
// Once the dialog is opened, show the next announcement
|
}
|
||||||
if (dialog.value) {
|
|
||||||
nextAnnouncement();
|
|
||||||
|
|
||||||
// If there are no new announcements, this is never set, so show the newest one
|
// Show first unread on open, or fall back to the newest
|
||||||
if (!currentAnnouncement.value) {
|
const next = newAnnouncements.value.at(0) || allAnnouncements.at(-1)!;
|
||||||
setCurrentAnnouncement(allAnnouncements.at(-1)!);
|
setCurrentAnnouncement(next);
|
||||||
}
|
});
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
function setCurrentAnnouncement(announcement: Announcement) {
|
function setCurrentAnnouncement(announcement: Announcement) {
|
||||||
currentAnnouncement.value = announcement;
|
currentAnnouncement.value = announcement;
|
||||||
|
|||||||
Reference in New Issue
Block a user