From 82c8a49e5be0bf9a1a839b6b1581cb53186b341e Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 29 Jun 2022 12:07:38 +0200 Subject: [PATCH] fix: naming & add promise type to button #discussion_r909384722 --- src/lib/components/alert.svelte | 12 ++++++------ src/lib/layout/notification.svelte | 10 +++++----- src/lib/layout/notifications.svelte | 2 +- src/lib/stores/notifications.ts | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lib/components/alert.svelte b/src/lib/components/alert.svelte index 36e1ed44a..921f54b28 100644 --- a/src/lib/components/alert.svelte +++ b/src/lib/components/alert.svelte @@ -1,10 +1,10 @@ @@ -25,11 +25,11 @@

- {#if func?.length} + {#if buttons?.length}
- {#each func as f} - {/each}
diff --git a/src/lib/layout/notification.svelte b/src/lib/layout/notification.svelte index ca5b33c4b..7b77e5d51 100644 --- a/src/lib/layout/notification.svelte +++ b/src/lib/layout/notification.svelte @@ -4,7 +4,7 @@ export let type: Notification['type'] = 'info'; export let title: Notification['title']; - export let func: Notification['func']; + export let buttons: Notification['buttons']; let icon: string; switch (type) { @@ -44,11 +44,11 @@ {/if}

- {#if func} + {#if buttons}
- {#each func as f} - {/each}
diff --git a/src/lib/layout/notifications.svelte b/src/lib/layout/notifications.svelte index dde7dcdda..7b019f930 100644 --- a/src/lib/layout/notifications.svelte +++ b/src/lib/layout/notifications.svelte @@ -11,7 +11,7 @@ type={notification.type} title={notification.title} on:dismiss={() => dismissNotification(notification.id)} - func={notification?.func}> + buttons={notification?.buttons}> {notification.message} {/each} diff --git a/src/lib/stores/notifications.ts b/src/lib/stores/notifications.ts index ce67f7899..0642824df 100644 --- a/src/lib/stores/notifications.ts +++ b/src/lib/stores/notifications.ts @@ -7,11 +7,11 @@ export type Notification = { timeout?: number; message: string; title?: string; - func?: Func[]; + buttons?: Buttons[]; }; -export type Func = { - method: () => void; //TODO Check if promise is needed rather tha () => void +export type Buttons = { + method: () => void | Promise; name: string; };