From dcd8f305b61a6d3eda3a93ee7445534791432fb0 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Wed, 12 Apr 2023 17:38:45 -0400 Subject: [PATCH] chore: only gather notifications if not `return_notifications?` --- lib/ash/engine/engine.ex | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/ash/engine/engine.ex b/lib/ash/engine/engine.ex index c3bef976..17155731 100644 --- a/lib/ash/engine/engine.ex +++ b/lib/ash/engine/engine.ex @@ -161,21 +161,20 @@ defmodule Ash.Engine do if opts[:return_notifications?] do resource_notifications else - Ash.Notifier.notify(resource_notifications) - end + notifications = Ash.Notifier.notify(resource_notifications) - notifications = - if Process.get(:ash_engine_started_transaction?) do - current_notifications = Process.get(:ash_engine_notifications, []) + if Process.get(:ash_engine_started_transaction?) do + current_notifications = Process.get(:ash_engine_notifications, []) - Process.put( - :ash_engine_notifications, - current_notifications ++ notifications - ) + Process.put( + :ash_engine_notifications, + current_notifications ++ notifications + ) - [] - else - notifications + [] + else + notifications + end end {:ok, %{result | resource_notifications: notifications}}