chore: better notification handling

This commit is contained in:
Zach Daniel 2023-04-12 18:10:17 -04:00
parent dcd8f305b6
commit 911acdef5b

View file

@ -124,15 +124,21 @@ defmodule Ash.Engine do
) )
|> case do |> case do
{:ok, result} -> {:ok, result} ->
saved_notifications = Process.delete(:ash_engine_notifications) saved_notifications = Process.delete(:ash_engine_notifications) || []
remaining_notifications = Ash.Notifier.notify(saved_notifications)
if opts[:return_notifications?] do
{:ok, {:ok,
%{ %{
result result
| resource_notifications: | resource_notifications:
result.resource_notifications ++ remaining_notifications result.resource_notifications ++ saved_notifications
}} }}
else
remaining_notifications =
Ash.Notifier.notify(result.resource_notifications ++ saved_notifications)
{:ok, %{result | resource_notifications: remaining_notifications}}
end
{:error, error} -> {:error, error} ->
{:error, error} {:error, error}