Closed gfyans closed 2 years ago
Hi,
I think the way to go would be the second option, detecting if uSync is the thing that has caused the notification to happen.
within Umbraco 9 you can't actually stop the events (the save/publish api calls no longer let you not raise them) and i think there is so much tied into the events (cacheing etc) its best to make sure they get called.
but uSync already has a mechanism it uses to make sure it doesn't trigger on its self when imports are creating events.
n.b this is a little diffrent for v9 and v8 versions of uSync.
you can inject the uSyncEventService
and then check if uSync is Paused (which is true when it is importing, it pauses it self. )
e.g if you has the eventService in your notification handler like this:
uSyncEventService _uSyncEventService
then at the top of an event you could check it, and exit if paused is true like this
if (_uSyncEventService.IsPaused) return false;
you can see this inside uSync's own notification events (https://github.com/KevinJump/uSync/blob/v9/main/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs#L1066)
its actually a bit simpler for v8 as there is a static class managing the paused status so a single check
if (uSync8BackOffice.eventsPaused) return;
does the same thing.
Thanks for the tip, Kevin. I've implemented this into our Handlers and it's doing the job.
Disclosure: We're only trialling uSync Complete for now
Is your feature request related to a problem? Please describe. We have a series of Notification Handlers to create default nodes under newly created nodes. When importing content using Publisher, the notification handlers are called which create our default nodes. The default node are a part of the Publisher sync, so we want to disable raising handling notifications.
Describe the solution you'd like I think there should be a setting for Publisher that allows you to disable raising events.
Describe alternatives you've considered An alternative would be detecting within the Notification Handler that uSync is creating the node, and therefore we can choose to skip it in code. I don't know if it's possible to detect is uSync is creating the node though.
Additional context I've attached a screenshot of the problem.![2022-02-01_11h49_28](https://user-images.githubusercontent.com/1040786/151963627-7da39670-547c-4ab0-b0f6-dd1f15f29885.png)