<commit_before>import R from 'ramda';
import React from 'react';

import SVGLayer from './SVGLayer';
import XODLink from './Link';
import { addPoints } from '../nodeLayout';

class DraggedNodeLinksLayer extends React.PureComponent {
  getLinksWithUpdatedPositions() {
    const {
      node,
      nodePosition,
      links,
    } = this.props;

    return R.map(
      (link) => {
        const indexOfPinConnectedToTheDraggedNode =
          R.findIndex(R.propEq('nodeId', node.id), link.pins);

        const draggedPinKey = link.pins[indexOfPinConnectedToTheDraggedNode].pinKey;
        const pinPosition = addPoints(
          nodePosition,
          node.pins[draggedPinKey].position
        );

        const pinPositionKey = ['from', 'to'][indexOfPinConnectedToTheDraggedNode];

        return R.assoc(pinPositionKey, pinPosition, link);
      },
      links
    );
  }

  render() {
    if (!this.props.node) return null;

    const links = this.getLinksWithUpdatedPositions();

    return (
      <SVGLayer
        name="DraggedNodeLinksLayer"
        className="DraggedNodeLinksLayer"
      >
        {links.map(link =>
          <XODLink
            key={link.id}
            id={link.id}
            from={link.from}
            to={link.to}
            type={link.type}
          />
        )}<commit_msg>tweak(xod-client): extract link updating function from getLinksWithUpdatedPositions<commit_after>import R from 'ramda';
import React from 'react';

import SVGLayer from './SVGLayer';
import XODLink from './Link';
import { addPoints } from '../nodeLayout';

const updatePinPositions = R.curry((node, newNodePosition, link) => {
  const indexOfPinConnectedToTheDraggedNode =
    R.findIndex(R.propEq('nodeId', node.id), link.pins);

  const draggedPinKey = link.pins[indexOfPinConnectedToTheDraggedNode].pinKey;
  const pinPosition = addPoints(
    newNodePosition,
    node.pins[draggedPinKey].position
  );

  const pinPositionKey = ['from', 'to'][indexOfPinConnectedToTheDraggedNode];

  return R.assoc(pinPositionKey, pinPosition, link);
});

class DraggedNodeLinksLayer extends React.PureComponent {
  getLinksWithUpdatedPositions() {
    const {
      node,
      nodePosition,
      links,
    } = this.props;

    return R.map(
      updatePinPositions(node, nodePosition),
      links
    );
  }

  render() {
    if (!this.props.node) return null;

    const links = this.getLinksWithUpdatedPositions();

    return (
      <SVGLayer
        name="DraggedNodeLinksLayer"
        className="DraggedNodeLinksLayer"
      >
        {links.map(link =>
          <XODLink
            key={link.id}
            id={link.id}
            from={link.from}
            to={link.to}
            type={link.type}
          />
        )}
{'fraction_non_alphanumeric': 0.11486732097419121, 'fraction_numerical': 0.0, 'mean_word_length': 2.569390402075227, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '3523509', 'n_tokens_mistral': 841, 'n_tokens_neox': 820, 'n_words': 160}