Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documents under workflow aren't handled if the document is moved in the tree #33

Closed
jkerb135 opened this issue Sep 7, 2023 · 2 comments

Comments

@jkerb135
Copy link

jkerb135 commented Sep 7, 2023

When moving documents in the Tree the event triggered is "DocumentEvents.Update" if this page is under workflow the task will be skipped in the DefaultAlgoliaTaskLogger.

if ((eventName.Equals(DocumentEvents.Insert.Name, StringComparison.OrdinalIgnoreCase) || eventName.Equals(DocumentEvents.Update.Name, StringComparison.OrdinalIgnoreCase)) && node.GetWorkflow() != null)
 {
      // Do not handle Insert/Update for pages under workflow
      return;
 }

This will cause the indexed data to become invalid if there are path specific values built using the parents nodeid or path.

A workaround I have implemented in a custom module to force send the task on update with the event name of publish if the changed columns contain "NodeParentID"

DocumentEvents.Update.Before += ForceMoveUpdate

 private void ForceMoveUpdate(object sender, DocumentEventArgs e)
    {
        var columns = e.Node.ChangedColumns();
        if (columns.Any(col => col.Equals(nameof(TreeNode.NodeParentID), StringComparison.OrdinalIgnoreCase)))
        {
            algoliaTaskLogger.HandleEvent(e.Node, WorkflowEvents.Publish.Name);
        }
    }
@ondrejhenek
Copy link
Contributor

Hi! Thanks for sharing your problem and a solution! We'll take a look at it soon and consider adding it to the original integration.

@bkapustik
Copy link
Collaborator

Hello, this workaround has been implemented in the following pull request.
#34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants