1
0
Fork 0
mirror of synced 2024-07-03 21:40:55 +12:00

Add count to duplicate errors (#10920)

* Add count to duplicate errors

* Lint: Remove unused prop
This commit is contained in:
melohagan 2023-06-23 18:34:05 +01:00 committed by GitHub
parent ca4011e292
commit 8325b5bb1e
3 changed files with 15 additions and 4 deletions

View file

@ -21,7 +21,6 @@
export let allowHelpers = true
export let updateOnChange = true
export let drawerLeft
export let key
const dispatch = createEventDispatcher()
let bindingDrawer

View file

@ -6,7 +6,7 @@
<div class="notifications">
{#if $notificationStore}
{#each $notificationStore as { type, icon, message, id, dismissable } (id)}
{#each $notificationStore as { type, icon, message, id, dismissable, count } (id)}
<div
in:fly={{
duration: 300,
@ -17,7 +17,7 @@
>
<Notification
{type}
{message}
message={count > 1 ? `(${count}) ${message}` : message}
{icon}
{dismissable}
on:dismiss={() => notificationStore.actions.dismiss(id)}

View file

@ -13,7 +13,13 @@ const createNotificationStore = () => {
setTimeout(() => (block = false), timeout)
}
const send = (message, type = "info", icon, autoDismiss = true) => {
const send = (
message,
type = "info",
icon,
autoDismiss = true,
count = 1
) => {
if (block) {
return
}
@ -33,6 +39,11 @@ const createNotificationStore = () => {
}
const _id = id()
store.update(state => {
const duplicateError = state.find(err => err.message === message)
if (duplicateError) {
duplicateError.count += 1
return [...state]
}
return [
...state,
{
@ -42,6 +53,7 @@ const createNotificationStore = () => {
icon,
dismissable: !autoDismiss,
delay: get(store) != null,
count,
},
]
})