From da7c9fb2fb11efd38101335d108b9e8f8e5abacc Mon Sep 17 00:00:00 2001 From: Kevin Jump Date: Mon, 31 Jul 2023 10:28:52 +0100 Subject: [PATCH] #523 - listd for ContainerRename events as these fire on rename and save doesn't. (#524) --- .../SyncHandlers/Handlers/ContentTypeHandler.cs | 3 ++- .../SyncHandlers/Handlers/DataTypeHandler.cs | 3 ++- .../SyncHandlers/Handlers/MediaTypeHandler.cs | 3 ++- .../SyncHandlers/Handlers/MemberTypeHandler.cs | 4 +++- .../SyncHandlers/SyncHandlerContainerBase.cs | 13 ++++++++++++- .../uSyncBackOfficeBuilderExtensions.cs | 5 +++++ 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/uSync.BackOffice/SyncHandlers/Handlers/ContentTypeHandler.cs b/uSync.BackOffice/SyncHandlers/Handlers/ContentTypeHandler.cs index 1dbcde53..15300956 100644 --- a/uSync.BackOffice/SyncHandlers/Handlers/ContentTypeHandler.cs +++ b/uSync.BackOffice/SyncHandlers/Handlers/ContentTypeHandler.cs @@ -28,7 +28,8 @@ public class ContentTypeHandler : SyncHandlerContainerBase>, INotificationHandler>, INotificationHandler>, - INotificationHandler + INotificationHandler, + INotificationHandler { private readonly IContentTypeService contentTypeService; diff --git a/uSync.BackOffice/SyncHandlers/Handlers/DataTypeHandler.cs b/uSync.BackOffice/SyncHandlers/Handlers/DataTypeHandler.cs index add82808..b13b461d 100644 --- a/uSync.BackOffice/SyncHandlers/Handlers/DataTypeHandler.cs +++ b/uSync.BackOffice/SyncHandlers/Handlers/DataTypeHandler.cs @@ -31,7 +31,8 @@ public class DataTypeHandler : SyncHandlerContainerBase>, INotificationHandler>, INotificationHandler>, - INotificationHandler + INotificationHandler, + INotificationHandler { private readonly IDataTypeService dataTypeService; diff --git a/uSync.BackOffice/SyncHandlers/Handlers/MediaTypeHandler.cs b/uSync.BackOffice/SyncHandlers/Handlers/MediaTypeHandler.cs index 3f3d0611..483bce87 100644 --- a/uSync.BackOffice/SyncHandlers/Handlers/MediaTypeHandler.cs +++ b/uSync.BackOffice/SyncHandlers/Handlers/MediaTypeHandler.cs @@ -28,7 +28,8 @@ public class MediaTypeHandler : SyncHandlerContainerBase>, INotificationHandler>, INotificationHandler>, - INotificationHandler + INotificationHandler, + INotificationHandler // INotificationHandler { private readonly IMediaTypeService mediaTypeService; diff --git a/uSync.BackOffice/SyncHandlers/Handlers/MemberTypeHandler.cs b/uSync.BackOffice/SyncHandlers/Handlers/MemberTypeHandler.cs index 22dc0cd2..9f3bcf8f 100644 --- a/uSync.BackOffice/SyncHandlers/Handlers/MemberTypeHandler.cs +++ b/uSync.BackOffice/SyncHandlers/Handlers/MemberTypeHandler.cs @@ -27,7 +27,9 @@ namespace uSync.BackOffice.SyncHandlers.Handlers public class MemberTypeHandler : SyncHandlerContainerBase, ISyncHandler, INotificationHandler>, INotificationHandler>, - INotificationHandler> + INotificationHandler>, + INotificationHandler, + INotificationHandler { private readonly IMemberTypeService memberTypeService; diff --git a/uSync.BackOffice/SyncHandlers/SyncHandlerContainerBase.cs b/uSync.BackOffice/SyncHandlers/SyncHandlerContainerBase.cs index 928999d3..2e5a31f6 100644 --- a/uSync.BackOffice/SyncHandlers/SyncHandlerContainerBase.cs +++ b/uSync.BackOffice/SyncHandlers/SyncHandlerContainerBase.cs @@ -144,7 +144,18 @@ public virtual void Handle(EntityContainerSavedNotification notification) { if (_mutexService.IsPaused) return; - foreach (var folder in notification.SavedEntities) + ProcessContainerChanges(notification.SavedEntities); + } + + public virtual void Handle(EntityContainerRenamedNotification notification) + { + if (_mutexService.IsPaused) return; + ProcessContainerChanges(notification.Entities); + } + + private void ProcessContainerChanges(IEnumerable containers) + { + foreach (var folder in containers) { if (folder.ContainedObjectType == this.itemObjectType.GetGuid()) { diff --git a/uSync.BackOffice/uSyncBackOfficeBuilderExtensions.cs b/uSync.BackOffice/uSyncBackOfficeBuilderExtensions.cs index c5320c6d..4d66d51d 100644 --- a/uSync.BackOffice/uSyncBackOfficeBuilderExtensions.cs +++ b/uSync.BackOffice/uSyncBackOfficeBuilderExtensions.cs @@ -127,20 +127,25 @@ internal static void AddHandlerNotifications(this IUmbracoBuilder builder) builder.AddNotificationHandler(); builder.AddNotificationHandler(); builder.AddNotificationHandler(); + builder.AddNotificationHandler(); builder.AddNotificationHandler(); builder.AddNotificationHandler(); builder.AddNotificationHandler(); builder.AddNotificationHandler(); + builder.AddNotificationHandler(); builder.AddNotificationHandler(); builder.AddNotificationHandler(); builder.AddNotificationHandler(); builder.AddNotificationHandler(); + builder.AddNotificationHandler(); builder.AddNotificationHandler(); builder.AddNotificationHandler(); builder.AddNotificationHandler(); + builder.AddNotificationHandler(); + builder.AddNotificationHandler(); builder.AddNotificationHandler(); builder.AddNotificationHandler();