Fix (notification): being closed by prev notification early
This commit is contained in:
11
tui.go
11
tui.go
@@ -38,6 +38,7 @@ var (
|
|||||||
roleEditWindow *tview.InputField
|
roleEditWindow *tview.InputField
|
||||||
shellInput *tview.InputField
|
shellInput *tview.InputField
|
||||||
confirmModal *tview.Modal
|
confirmModal *tview.Modal
|
||||||
|
toastTimer *time.Timer
|
||||||
confirmPageName = "confirm"
|
confirmPageName = "confirm"
|
||||||
fullscreenMode bool
|
fullscreenMode bool
|
||||||
positionVisible bool = true
|
positionVisible bool = true
|
||||||
@@ -156,10 +157,11 @@ func showToast(title, message string) {
|
|||||||
}
|
}
|
||||||
title = sanitize(title, 50)
|
title = sanitize(title, 50)
|
||||||
message = sanitize(message, 197)
|
message = sanitize(message, 197)
|
||||||
|
if toastTimer != nil {
|
||||||
|
toastTimer.Stop()
|
||||||
|
}
|
||||||
notificationWidget.SetTitle(title)
|
notificationWidget.SetTitle(title)
|
||||||
notificationWidget.SetText(fmt.Sprintf("[yellow]%s[-]", message))
|
notificationWidget.SetText(fmt.Sprintf("[yellow]%s[-]", message))
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
app.QueueUpdateDraw(func() {
|
app.QueueUpdateDraw(func() {
|
||||||
flex.RemoveItem(bottomFlex)
|
flex.RemoveItem(bottomFlex)
|
||||||
@@ -173,8 +175,7 @@ func showToast(title, message string) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
|
toastTimer = time.AfterFunc(3*time.Second, func() {
|
||||||
time.AfterFunc(3*time.Second, func() {
|
|
||||||
app.QueueUpdateDraw(func() {
|
app.QueueUpdateDraw(func() {
|
||||||
flex.RemoveItem(bottomFlex)
|
flex.RemoveItem(bottomFlex)
|
||||||
flex.RemoveItem(statusLineWidget)
|
flex.RemoveItem(statusLineWidget)
|
||||||
@@ -299,11 +300,9 @@ func init() {
|
|||||||
SetChangedFunc(func() {
|
SetChangedFunc(func() {
|
||||||
})
|
})
|
||||||
notificationWidget.SetBorder(true).SetTitle("notification")
|
notificationWidget.SetBorder(true).SetTitle("notification")
|
||||||
|
|
||||||
bottomFlex = tview.NewFlex().SetDirection(tview.FlexColumn).
|
bottomFlex = tview.NewFlex().SetDirection(tview.FlexColumn).
|
||||||
AddItem(textArea, 0, 1, true).
|
AddItem(textArea, 0, 1, true).
|
||||||
AddItem(notificationWidget, 0, 0, false)
|
AddItem(notificationWidget, 0, 0, false)
|
||||||
|
|
||||||
//
|
//
|
||||||
flex = tview.NewFlex().SetDirection(tview.FlexRow).
|
flex = tview.NewFlex().SetDirection(tview.FlexRow).
|
||||||
AddItem(textView, 0, 40, false).
|
AddItem(textView, 0, 40, false).
|
||||||
|
|||||||
Reference in New Issue
Block a user