Skip to content

Commit d690c0c

Browse files
committed
Make timeout a variable
1 parent 72a2d10 commit d690c0c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/utils/Notification.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ let currentModeMessage: Notification = null;
1111
*/
1212
const NUMBER_TO_DISPLAY = 3;
1313

14+
/**
15+
* Number of notifications to display at a time.
16+
*/
17+
const TIMEOUT = 5000;
18+
1419
const notificationIcon: Record<NotificationType, string> = {
1520
default: '',
1621
warning: '⚠️ ',
@@ -60,7 +65,7 @@ export class Notification {
6065
}
6166

6267
/**
63-
* Clear the notifications if no more exist or display another from the queue.
68+
* Clear the notification
6469
* @param currentId - The ID of the notification to be cleared.
6570
*/
6671
function clearNotification (currentId: string): void {
@@ -107,15 +112,14 @@ function displayNotification (notification: Notification): void {
107112
function startNotification (notification: Notification): void {
108113
displayNotification(notification);
109114
notification.setTimeoutId(
110-
window.setTimeout(clearNotification, 5000, notification.getId())
115+
window.setTimeout(clearNotification, TIMEOUT, notification.getId())
111116
);
112117
document
113118
.getElementById(notification.getId())
114119
.addEventListener('click', () => {
115120
window.clearTimeout(notification.timeoutID);
116121
clearNotification(notification.getId());
117122
});
118-
119123
}
120124

121125
/**

0 commit comments

Comments
 (0)