Skip to content

Commit

Permalink
More credo fixes and deprecated non-conformant calls
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicletz committed Oct 15, 2024
1 parent 4fc6ea3 commit 96122df
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/desktop/fallback.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Desktop.Fallback do
end

defp check_has_webview() do
if is_module?(:wxWebView) do
if module?(:wxWebView) do
:ok
else
{:error, "Missing support for wxWebView - upgrade to OTP/24. Will show OS browser instead"}
Expand Down Expand Up @@ -112,7 +112,7 @@ defmodule Desktop.Fallback do
def webview_can_fix(nil), do: false

def webview_can_fix(webview) do
is_module?(:wxWebView) and OS.type() == Windows and
module?(:wxWebView) and OS.type() == Windows and
backend_available?("wxWebViewEdge") and
call(:wxWebView, :isShownOnScreen, [webview])
end
Expand Down Expand Up @@ -163,7 +163,7 @@ defmodule Desktop.Fallback do
end

def notification_new(title, type) do
if is_module?(:wxNotificationMessage) do
if module?(:wxNotificationMessage) do
flag =
case type do
:info -> Wx.wxICON_INFORMATION()
Expand Down Expand Up @@ -196,7 +196,7 @@ defmodule Desktop.Fallback do
end

def notification_show(notification, message, timeout, title \\ nil) do
if is_module?(:wxNotificationMessage) do
if module?(:wxNotificationMessage) do
if title != nil do
call(:wxNotificationMessage, :setTitle, [notification, to_charlist(title)])
end
Expand All @@ -220,7 +220,7 @@ defmodule Desktop.Fallback do
call(:wx, :get_env)
end

defp is_module?(module) do
defp module?(module) do
Code.ensure_compiled(module) == {:module, module}
end

Expand Down
18 changes: 16 additions & 2 deletions lib/desktop/window.ex
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,17 @@ defmodule Desktop.Window do
false
"""
def is_hidden?(pid) do
def hidden?(pid) do
GenServer.call(pid, :is_hidden?)
end

@doc false
@deprecated "Use hidden?/1 instead"
# credo:disable-for-next-line
def is_hidden?(pid) do
hidden?(pid)
end

@doc """
Returns true if the window is active. Always returns true
on mobile platforms.
Expand All @@ -286,10 +293,17 @@ defmodule Desktop.Window do
false
"""
def is_active?(pid) do
def active?(pid) do
GenServer.call(pid, :is_active?)
end

@doc false
@deprecated "Use active?/1 instead"
# credo:disable-for-next-line
def is_active?(pid) do
active?(pid)
end

@doc """
Set the windows title
Expand Down

0 comments on commit 96122df

Please sign in to comment.