<commit_before>import React from 'react';

export default function MarkingsRenderer(props) {
  // a list that holds the annotations for the current combo task
  let currentComboAnnotations = [];
  const allTaskTypes = props.classification.annotations.map( annotation => props.workflow.tasks[annotation.task].type);
  const i = allTaskTypes.lastIndexOf('combo');
  if (i > -1) {
    currentComboAnnotations = props.classification.annotations[i].value;
  }
  // a list that holds the annotations for all combo tasks
  let allComboAnnotations = [];
  const allComboTypes = [];
  props.classification.annotations.map( (annotation) => {
    const taskDescription = props.workflow.tasks[annotation.task];
    if (taskDescription.type === 'combo') {
      allComboAnnotations = allComboAnnotations.concat(annotation.value);
      annotation.value.map((a) => {
        allComboTypes.push(props.workflow.tasks[a.task].type);
      });
    }
  });


  return (
    <g className="combo-task-persist-inside-subject-container">
      {Object.keys(props.taskTypes)
        .filter((taskType) => { return taskType !== 'combo'; })
        .map((taskType) => {
          const TaskComponent = props.taskTypes[taskType];
          if (TaskComponent.PersistInsideSubject) {
            // when a combo annotation changes make sure the combo annotation updated correctly with only the
            // curreny combo task's annotatons.  This is a hack to make drawing tasks work in a combo task.
            function fauxChange(annotation) {
              props.onChange(Object.assign({}, props.annotation, { value: currentComboAnnotations }));
            };
            let fauxAnnotation = props.annotation;
            if (props.annotation && props.annotation.task && props.workflow.tasks && props.workflow.tasks[props.annotation.task].type === 'combo') {
              const idx = allComboTypes.lastIndexOf(taskType);
              if (idx > -1) {
                // if the current annotation is for the combo task pass in the `inner` annotations
                //This is a hack to make drawing tasks work in a combo task.
                fauxAnnotation = allComboAnnotations[idx];
              }
            }
            return (
              <TaskComponent.PersistInsideSubject
                key={taskType}
                {...props}
                onChange={fauxChange}
                annotations={allComboAnnotations}
                annotation={fauxAnnotation}
              />
            );
          }
        })
      }
  </g>
  );
}<commit_msg>Tidy up fauxAnnotation<commit_after>import React from 'react';

export default function MarkingsRenderer(props) {
  // a list that holds the annotations for the current combo task
  let currentComboAnnotations = [];
  const allTaskTypes = props.classification.annotations.map( annotation => props.workflow.tasks[annotation.task].type);
  const i = allTaskTypes.lastIndexOf('combo');
  if (i > -1) {
    currentComboAnnotations = props.classification.annotations[i].value;
  }
  // a list that holds the annotations for all combo tasks
  let allComboAnnotations = [];
  const allComboTypes = [];
  props.classification.annotations.map( (annotation) => {
    const taskDescription = props.workflow.tasks[annotation.task];
    if (taskDescription.type === 'combo') {
      allComboAnnotations = allComboAnnotations.concat(annotation.value);
      annotation.value.map((a) => {
        allComboTypes.push(props.workflow.tasks[a.task].type);
      });
    }
  });


  return (
    <g className="combo-task-persist-inside-subject-container">
      {Object.keys(props.taskTypes)
        .filter((taskType) => { return taskType !== 'combo'; })
        .map((taskType) => {
          const TaskComponent = props.taskTypes[taskType];
          if (TaskComponent.PersistInsideSubject) {
            // when a combo annotation changes make sure the combo annotation updated correctly with only the
            // curreny combo task's annotatons.  This is a hack to make drawing tasks work in a combo task.
            function fauxChange(annotation) {
              props.onChange(Object.assign({}, props.annotation, { value: currentComboAnnotations }));
            };
            let {annotation} = props;
            if (annotation &&
              annotation.task &&
              props.workflow.tasks &&
              props.workflow.tasks[annotation.task].type === 'combo'
            ) {
              const idx = allComboTypes.lastIndexOf(taskType);
              if (idx > -1) {
                // if the current annotation is for the combo task pass in the `inner` annotations
                //This is a hack to make drawing tasks work in a combo task.
                annotation = allComboAnnotations[idx];
              }
            }
            return (
              <TaskComponent.PersistInsideSubject
                key={taskType}
                {...props}
                onChange={fauxChange}
                annotations={allComboAnnotations}
                annotation={annotation}
              />
            );
          }
        })
      }
  </g>
  );
}
{'fraction_non_alphanumeric': 0.10756894191277137, 'fraction_numerical': 0.0007823195775474281, 'mean_word_length': 2.2244640605296344, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3624237', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1319, 'n_words': 330}