@@ -10,6 +10,7 @@ import { LayerType } from "../../../RootView"
10
10
import type { ClickHandler } from "./GuiUtils"
11
11
import { assertMainOrNode } from "../../api/common/Env"
12
12
import { debounce , isEmpty , remove } from "@tutao/tutanota-utils"
13
+ import { IconButton , IconButtonAttrs } from "./IconButton"
13
14
14
15
assertMainOrNode ( )
15
16
const SNACKBAR_SHOW_TIME = 6000
@@ -21,6 +22,7 @@ export type SnackBarButtonAttrs = {
21
22
type SnackBarAttrs = {
22
23
message : MaybeTranslation
23
24
button : ButtonAttrs | null
25
+ dismissButton ?: IconButtonAttrs
24
26
}
25
27
type QueueItem = SnackBarAttrs & {
26
28
onClose : ( ( timedOut : boolean ) => unknown ) | null
@@ -39,6 +41,7 @@ class SnackBar implements Component<SnackBarAttrs> {
39
41
return m ( ".snackbar-content.flex.flex-space-between.border-radius.plr.pb-xs.pt-xs" , [
40
42
m ( ".flex.center-vertically.smaller" , lang . getTranslationText ( vnode . attrs . message ) ) ,
41
43
vnode . attrs . button ? m ( ".flex-end.center-vertically.pl" , m ( Button , vnode . attrs . button ) ) : null ,
44
+ vnode . attrs . dismissButton ? m ( ".flex.items-center.justify-right" , [ m ( IconButton , vnode . attrs . dismissButton ) ] ) : null ,
42
45
] )
43
46
}
44
47
}
@@ -66,13 +69,14 @@ function makeButtonAttrsForSnackBar(button: SnackBarButtonAttrs): ButtonAttrs {
66
69
export function showSnackBar ( args : {
67
70
message : MaybeTranslation
68
71
button : SnackBarButtonAttrs
72
+ dismissButton ?: IconButtonAttrs
69
73
onShow ?: ( ) => unknown
70
74
onClose ?: ( timedOut : boolean ) => unknown
71
75
waitingTime ?: number
72
76
showingTime ?: number
73
77
replace ?: boolean
74
78
} ) : ( ) => void {
75
- const { message, button, onClose, onShow, waitingTime, showingTime = SNACKBAR_SHOW_TIME , replace = false } = args
79
+ const { message, button, dismissButton , onClose, onShow, waitingTime, showingTime = SNACKBAR_SHOW_TIME , replace = false } = args
76
80
77
81
let cancelled = false
78
82
const doCancel = {
@@ -82,9 +86,11 @@ export function showSnackBar(args: {
82
86
}
83
87
84
88
const buttonAttrs = makeButtonAttrsForSnackBar ( button )
89
+
85
90
const queueEntry : QueueItem = {
86
91
message : message ,
87
92
button : buttonAttrs ,
93
+ dismissButton : dismissButton ,
88
94
onClose : onClose ?? null ,
89
95
onShow : onShow ?? null ,
90
96
doCancel,
@@ -144,7 +150,7 @@ function getSnackBarPosition() {
144
150
}
145
151
146
152
function showNextNotification ( ) {
147
- const { message, button, onClose, onShow, doCancel, showingTime } = notificationQueue [ 0 ] //we shift later because it is still shown
153
+ const { message, button, dismissButton , onClose, onShow, doCancel, showingTime } = notificationQueue [ 0 ] //we shift later because it is still shown
148
154
clearTimeout ( currentAnimationTimeout )
149
155
currentAnimationTimeout = null
150
156
const closeFunction = displayOverlay (
@@ -154,6 +160,7 @@ function showNextNotification() {
154
160
m ( SnackBar , {
155
161
message,
156
162
button,
163
+ dismissButton : dismissButton ,
157
164
} ) ,
158
165
} ,
159
166
"slide-bottom" ,
0 commit comments