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 allowHelpers = true
|
||||||
export let updateOnChange = true
|
export let updateOnChange = true
|
||||||
export let drawerLeft
|
export let drawerLeft
|
||||||
export let key
|
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let bindingDrawer
|
let bindingDrawer
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<div class="notifications">
|
<div class="notifications">
|
||||||
{#if $notificationStore}
|
{#if $notificationStore}
|
||||||
{#each $notificationStore as { type, icon, message, id, dismissable } (id)}
|
{#each $notificationStore as { type, icon, message, id, dismissable, count } (id)}
|
||||||
<div
|
<div
|
||||||
in:fly={{
|
in:fly={{
|
||||||
duration: 300,
|
duration: 300,
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
>
|
>
|
||||||
<Notification
|
<Notification
|
||||||
{type}
|
{type}
|
||||||
{message}
|
message={count > 1 ? `(${count}) ${message}` : message}
|
||||||
{icon}
|
{icon}
|
||||||
{dismissable}
|
{dismissable}
|
||||||
on:dismiss={() => notificationStore.actions.dismiss(id)}
|
on:dismiss={() => notificationStore.actions.dismiss(id)}
|
||||||
|
|
|
@ -13,7 +13,13 @@ const createNotificationStore = () => {
|
||||||
setTimeout(() => (block = false), timeout)
|
setTimeout(() => (block = false), timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
const send = (message, type = "info", icon, autoDismiss = true) => {
|
const send = (
|
||||||
|
message,
|
||||||
|
type = "info",
|
||||||
|
icon,
|
||||||
|
autoDismiss = true,
|
||||||
|
count = 1
|
||||||
|
) => {
|
||||||
if (block) {
|
if (block) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -33,6 +39,11 @@ const createNotificationStore = () => {
|
||||||
}
|
}
|
||||||
const _id = id()
|
const _id = id()
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
|
const duplicateError = state.find(err => err.message === message)
|
||||||
|
if (duplicateError) {
|
||||||
|
duplicateError.count += 1
|
||||||
|
return [...state]
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
...state,
|
...state,
|
||||||
{
|
{
|
||||||
|
@ -42,6 +53,7 @@ const createNotificationStore = () => {
|
||||||
icon,
|
icon,
|
||||||
dismissable: !autoDismiss,
|
dismissable: !autoDismiss,
|
||||||
delay: get(store) != null,
|
delay: get(store) != null,
|
||||||
|
count,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue