Fix NotifierFilter
Don't assume the action is executed by a controller
This commit is contained in:
parent
3f153c0f13
commit
d3032a8a7a
|
|
@ -2,6 +2,7 @@ using Elsa.Dashboard.Extensions;
|
|||
using Elsa.Dashboard.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
|
||||
namespace Elsa.Dashboard.ActionFilters
|
||||
{
|
||||
|
|
@ -9,10 +10,12 @@ namespace Elsa.Dashboard.ActionFilters
|
|||
{
|
||||
public const string TempDataKey = "Elsa:Notifications";
|
||||
private readonly INotifier notifier;
|
||||
private readonly ITempDataDictionaryFactory tempDataDictionaryFactory;
|
||||
|
||||
public NotifierFilter(INotifier notifier)
|
||||
public NotifierFilter(INotifier notifier, ITempDataDictionaryFactory tempDataDictionaryFactory)
|
||||
{
|
||||
this.notifier = notifier;
|
||||
this.tempDataDictionaryFactory = tempDataDictionaryFactory;
|
||||
}
|
||||
|
||||
public void OnActionExecuting(ActionExecutingContext context)
|
||||
|
|
@ -21,7 +24,7 @@ namespace Elsa.Dashboard.ActionFilters
|
|||
|
||||
public void OnActionExecuted(ActionExecutedContext context)
|
||||
{
|
||||
var tempData = ((Controller) context.Controller).TempData;
|
||||
var tempData = tempDataDictionaryFactory.GetTempData(context.HttpContext);
|
||||
|
||||
if (tempData.ContainsKey(TempDataKey))
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue