@@ -430,9 +430,7 @@ defmodule Desktop.Window do
430430
431431 ## Examples
432432
433- iex> :wx.set_env(Desktop.Env.wx_env())
434- iex> :wxWebView.isContextMenuEnabled(Desktop.Window.webview(pid))
435- false
433+ iex> Desktop.Window.show_notification(pid, "Hello, world!")
436434
437435 """
438436 def show_notification ( pid , text , opts \\ [ ] ) do
@@ -459,6 +457,13 @@ defmodule Desktop.Window do
459457 GenServer . cast ( pid , { :show_notification , text , id , type , title , callback , timeout } )
460458 end
461459
460+ @ doc """
461+ Dismiss a notification
462+ """
463+ def dismiss_notification ( pid , id ) do
464+ GenServer . cast ( pid , { :dismiss_notification , id } )
465+ end
466+
462467 @ doc """
463468 Quit the application. This forces a quick termination which can
464469 be helpful on MacOS/Windows as sometimes the destruction is
@@ -600,6 +605,17 @@ defmodule Desktop.Window do
600605 { :noreply , % Window { ui | notifications: noties } }
601606 end
602607
608+ def handle_cast ( { :dismiss_notification , id } , ui = % Window { notifications: noties } ) do
609+ case Map . pop ( noties , id ) do
610+ { nil , _noties } ->
611+ { :noreply , ui }
612+
613+ { { note , _callback } , noties } ->
614+ Fallback . notification_close ( note )
615+ { :noreply , % Window { ui | notifications: noties } }
616+ end
617+ end
618+
603619 def handle_cast ( { :show , url } , ui = % Window { home_url: home , last_url: last } ) do
604620 new_url = prepare_url ( url || last || home )
605621 Logger . info ( "Showing #{ new_url } " )
0 commit comments