Skip to content

Commit 59bf274

Browse files
fix: repair notification cast compile error and harden nil handling
Bind frame in show_notification cast (was undefined), recreate wx notification when a stored id maps to nil, no-op notification_close/1 for nil, fix doc typo, and drop duplicate :dismiss callback on non-Linux. Co-authored-by: Dominic Letz <dominicletz@users.noreply.github.com>
1 parent eee0168 commit 59bf274

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

lib/desktop/fallback.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ defmodule Desktop.Fallback do
233233
end
234234
end
235235

236+
def notification_close(nil), do: :ok
237+
236238
def notification_close(notification) do
237239
call(:wxNotificationMessage, :close, [notification])
238240
end

lib/desktop/window.ex

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ defmodule Desktop.Window do
449449
* `:type` - One of `:info` `:error` `:warn` these will change
450450
how the notification will be displayed. The default is `:info`
451451
452-
* `:title` - An alternative title for the notificaion,
452+
* `:title` - An alternative title for the notification,
453453
when none is provided the current window title is used.
454454
455455
* `:timeout` - A timeout hint specifying how long the notification
@@ -554,8 +554,6 @@ defmodule Desktop.Window do
554554

555555
if OS.type() == Linux do
556556
notification(ui, obj, :action)
557-
else
558-
notification(ui, obj, :dismiss)
559557
end
560558

561559
{:noreply, ui}
@@ -659,13 +657,19 @@ defmodule Desktop.Window do
659657

660658
def handle_cast(
661659
{:show_notification, message, id, type, title, callback, timeout},
662-
ui = %Window{notifications: noties, title: window_title}
660+
ui = %Window{notifications: noties, title: window_title, frame: frame}
663661
) do
664662
{n, _} =
665663
note =
666664
case Map.get(noties, id, nil) do
667-
nil -> {Fallback.notification_new(title || window_title, type, frame), callback}
668-
{note, _} -> {note, callback}
665+
nil ->
666+
{Fallback.notification_new(title || window_title, type, frame), callback}
667+
668+
{nil, _} ->
669+
{Fallback.notification_new(title || window_title, type, frame), callback}
670+
671+
{note, _} ->
672+
{note, callback}
669673
end
670674

671675
Fallback.notification_show(n, message, timeout, title || window_title)

0 commit comments

Comments
 (0)