Skip to content

Commit

Permalink
fix: don't check emails every interval
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt committed Dec 29, 2024
1 parent ed1bb5a commit 2bbe09a
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions app/components/partials/notification/NotificationProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,46 @@ const { pause, resume } = useIntervalFn(
async () => {
pause();
if (calendar.value.reminderTimes.length > 0) {
checkAppointments();
}
resume();
},
(60 + randomNumber(2, 7)) * 1000,
{ immediate: false },
);
const { start, stop } = useTimeoutFn(
async () => {
if (can('MailerService.ListEmails').value) {
await mailerStore.checkEmails();
}
if (calendar.value.reminderTimes.length > 0) {
checkAppointments();
await checkAppointments();
}
resume();
},
(60 + randomNumber(2, 7)) * 1000,
{ immediate: false },
randomNumber(1, 7) * 1000,
);
async function toggleStream(): Promise<void> {
// Only stream notifications when a user is logged in and has a character selected
if (username.value !== null && activeChar.value !== null) {
useTimeoutFn(
async () => {
if (can('MailerService.ListEmails').value) {
await mailerStore.checkEmails();
}
if (calendar.value.reminderTimes.length > 0) {
await checkAppointments();
}
resume();
},
randomNumber(1, 7) * 1000,
);
start();
try {
startStream();
} catch (e) {
logger.error('exception during notification stream', e);
}
} else if (abort.value !== undefined) {
pause();
await stopStream();
pause();
stop();
notificatorStore.$reset();
}
}
Expand Down

0 comments on commit 2bbe09a

Please sign in to comment.