1
0
Fork 0
mirror of synced 2024-10-05 12:34:50 +13: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 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

View file

@ -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)}

View file

@ -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,
}, },
] ]
}) })