Skip to content

Commit

Permalink
One more fix
Browse files Browse the repository at this point in the history
Bug fix: Dupliate error notifications could time out
  • Loading branch information
chrishamm committed May 18, 2020
1 parent 8dbbdfc commit 4ee4cf7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/plugins/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ const defaults = {
let settings, openNotifications = []

export function makeNotification(type, title, message, timeout) {
if (timeout === undefined) {
timeout = (type === 'error' && settings.errorsPersistent) ? 0 : settings.timeout;
}

// If there is already an equal notification, reset its time and don't display a new one
const equalNotification = openNotifications.find(item => item.type === type && item.title == title && item.message === message);
if (equalNotification) {
equalNotification.resetTimeout();
if (timeout > 0) {
equalNotification.resetTimeout();
}
return equalNotification;
}

Expand All @@ -32,7 +38,7 @@ export function makeNotification(type, title, message, timeout) {
onClosed() {
openNotifications = openNotifications.filter(notification => notification !== item);
},
timeout: (timeout !== undefined) ? timeout : ((type === 'error' && settings.errorsPersistent) ? 0 : settings.timeout)
timeout
}, defaults);

switch (type) {
Expand Down

0 comments on commit 4ee4cf7

Please sign in to comment.