@@ -18,7 +18,7 @@ public abstract class ContentOfTypeCacheRefresherNotificationHandlerBase(
18
18
IDocumentNavigationQueryService documentNavigationQueryService ,
19
19
IContentService contentService ,
20
20
IIdKeyMap keyMap ,
21
- IServerRoleAccessor serverRoleAccessor ) : INotificationAsyncHandler < ContentCacheRefresherNotification >
21
+ IServerRoleAccessor serverRoleAccessor ) : INotificationAsyncHandler < ContentCacheRefresherNotification > , IDistributedCacheNotificationHandler
22
22
{
23
23
protected abstract string ContentTypeAlias { get ; }
24
24
protected abstract Task HandleContentOfTypeAsync ( IContent content ) ;
@@ -57,6 +57,18 @@ public async Task HandleAsync(ContentCacheRefresherNotification notification, Ca
57
57
{
58
58
// Branch refresh
59
59
Guid rootNodeKey = payload . Key ?? keyMap . GetKeyForId ( payload . Id , UmbracoObjectTypes . Document ) . ResultOr ( Guid . Empty ) ;
60
+
61
+ // Handle the branch root
62
+ if ( rootNodeKey != Guid . Empty )
63
+ {
64
+ IContent ? content = contentService . GetById ( rootNodeKey ) ;
65
+ if ( content != null && content . ContentType . Alias == ContentTypeAlias )
66
+ {
67
+ await HandleContentOfTypeAsync ( content ) ;
68
+ }
69
+ }
70
+
71
+ // Handle the descendants
60
72
if ( rootNodeKey != Guid . Empty && documentNavigationQueryService . TryGetDescendantsKeysOfType ( rootNodeKey , ContentTypeAlias , out IEnumerable < Guid > keys ) )
61
73
{
62
74
foreach ( Guid key in keys )
@@ -71,6 +83,20 @@ public async Task HandleAsync(ContentCacheRefresherNotification notification, Ca
71
83
}
72
84
else if ( payload . ChangeTypes . HasType ( TreeChangeTypes . RefreshAll ) )
73
85
{
86
+ // Handle root nodes
87
+ if ( documentNavigationQueryService . TryGetRootKeysOfType ( ContentTypeAlias , out IEnumerable < Guid > rootKeysOfType ) )
88
+ {
89
+ foreach ( Guid rootKey in rootKeysOfType )
90
+ {
91
+ IContent ? content = contentService . GetById ( rootKey ) ;
92
+ if ( content != null )
93
+ {
94
+ await HandleContentOfTypeAsync ( content ) ;
95
+ }
96
+ }
97
+ }
98
+
99
+ // Handle descendants
74
100
if ( documentNavigationQueryService . TryGetRootKeys ( out IEnumerable < Guid > rootKeys ) )
75
101
{
76
102
foreach ( Guid rootKey in rootKeys )
0 commit comments