Skip to content

Commit 9ab8b81

Browse files
authored
The preview hub throws an exception during DB upgrade (#16338)
1 parent a4a9a27 commit 9ab8b81

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Umbraco.Cms.Api.Management/Preview/PreviewHubUpdater.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
using Umbraco.Cms.Core.Cache;
33
using Umbraco.Cms.Core.Events;
44
using Umbraco.Cms.Core.Notifications;
5+
using Umbraco.Cms.Core.Services.Changes;
56
using Umbraco.Cms.Core.Sync;
7+
using Umbraco.Extensions;
68

79
namespace Umbraco.Cms.Api.Management.Preview;
810

@@ -26,13 +28,17 @@ public async Task HandleAsync(ContentCacheRefresherNotification args, Cancellati
2628
IHubContext<PreviewHub, IPreviewHub> hubContextInstance = _hubContext.Value;
2729
foreach (ContentCacheRefresher.JsonPayload payload in payloads)
2830
{
29-
var key = payload.Key; // keep it simple for now, ignore ChangeTypes
30-
if (key.HasValue is false)
31+
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshNode) is false)
32+
{
33+
continue;
34+
}
35+
36+
if (payload.Key.HasValue is false)
3137
{
3238
throw new InvalidOperationException($"No key is set for payload with id {payload.Id}");
3339
}
3440

35-
await hubContextInstance.Clients.All.refreshed(key.Value);
41+
await hubContextInstance.Clients.All.refreshed(payload.Key.Value);
3642
}
3743
}
3844
}

0 commit comments

Comments
 (0)