Add count to duplicate errors (#10920)
* Add count to duplicate errors * Lint: Remove unused prop
This commit is contained in:
parent
ca4011e292
commit
8325b5bb1e
|
@ -21,7 +21,6 @@
|
|||
export let allowHelpers = true
|
||||
export let updateOnChange = true
|
||||
export let drawerLeft
|
||||
export let key
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
let bindingDrawer
|
||||
|
|
|
@ -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)}
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
]
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue