Only concat the stored toasts with new toast when there are stored toasts
This commit is contained in:
@@ -30,13 +30,15 @@ function addToastToStorage(time, message) {
|
|||||||
var toasts = [{ 'time': time, 'message': message }]
|
var toasts = [{ 'time': time, 'message': message }]
|
||||||
var storedToasts = getStoredToasts();
|
var storedToasts = getStoredToasts();
|
||||||
console.log("Adding new notification to storage: ", toasts);
|
console.log("Adding new notification to storage: ", toasts);
|
||||||
toasts = toasts.concat(storedToasts);
|
if (storedToasts) {
|
||||||
console.log("Combined new and stored notifications: ", toasts);
|
toasts = toasts.concat(storedToasts);
|
||||||
toasts = toasts.filter((value, index, self) =>
|
console.log("Combined new and stored notifications: ", toasts);
|
||||||
index === self.findIndex((t) => (
|
toasts = toasts.filter((value, index, self) =>
|
||||||
t.time === value.time && t.message === value.message
|
index === self.findIndex((t) => (
|
||||||
))
|
t.time === value.time && t.message === value.message
|
||||||
)
|
))
|
||||||
|
)
|
||||||
|
}
|
||||||
console.log("Deduped stored notifications: ", toasts);
|
console.log("Deduped stored notifications: ", toasts);
|
||||||
localStorage.setItem("toasts", JSON.stringify(toasts));
|
localStorage.setItem("toasts", JSON.stringify(toasts));
|
||||||
navbarUpdateNotificationBellCount(toasts);
|
navbarUpdateNotificationBellCount(toasts);
|
||||||
|
|||||||
@@ -30,13 +30,15 @@ function addToastToStorage(time, message) {
|
|||||||
var toasts = [{ 'time': time, 'message': message }]
|
var toasts = [{ 'time': time, 'message': message }]
|
||||||
var storedToasts = getStoredToasts();
|
var storedToasts = getStoredToasts();
|
||||||
console.log("Adding new notification to storage: ", toasts);
|
console.log("Adding new notification to storage: ", toasts);
|
||||||
toasts = toasts.concat(storedToasts);
|
if (storedToasts) {
|
||||||
console.log("Combined new and stored notifications: ", toasts);
|
toasts = toasts.concat(storedToasts);
|
||||||
toasts = toasts.filter((value, index, self) =>
|
console.log("Combined new and stored notifications: ", toasts);
|
||||||
index === self.findIndex((t) => (
|
toasts = toasts.filter((value, index, self) =>
|
||||||
t.time === value.time && t.message === value.message
|
index === self.findIndex((t) => (
|
||||||
))
|
t.time === value.time && t.message === value.message
|
||||||
)
|
))
|
||||||
|
)
|
||||||
|
}
|
||||||
console.log("Deduped stored notifications: ", toasts);
|
console.log("Deduped stored notifications: ", toasts);
|
||||||
localStorage.setItem("toasts", JSON.stringify(toasts));
|
localStorage.setItem("toasts", JSON.stringify(toasts));
|
||||||
navbarUpdateNotificationBellCount(toasts);
|
navbarUpdateNotificationBellCount(toasts);
|
||||||
|
|||||||
Reference in New Issue
Block a user