<commit_before>import { Action, Anchor, Box, Col, Icon, Row, Rule, Text } from '@tlon/indigo-react';
import { Association, GraphNode, Group } from '@urbit/api';
import React, { ReactElement, useCallback, useEffect, useRef } from 'react';
import { Link, Redirect } from 'react-router-dom';
import GlobalApi from '~/logic/api/global';
import { roleForShip } from '~/logic/lib/group';
import { getPermalinkForGraph, referenceToPermalink } from '~/logic/lib/permalinks';
import { useCopy } from '~/logic/lib/useCopy';
import useHarkState from '~/logic/state/hark';
import Author from '~/views/components/Author';
import { Dropdown } from '~/views/components/Dropdown';
import RemoteContent from '~/views/components/RemoteContent';
import { PermalinkEmbed } from '../../permalinks/embed';

interface LinkItemProps {
  node: GraphNode;
  association: Association;
  resource: string; api: GlobalApi; group: Group; path: string; }
export const LinkItem = React.forwardRef((props: LinkItemProps, ref): ReactElement => {
  const {
    association,
    node,
    resource,
    api,
    group,
    path,
    ...rest
  } = props;

  if (typeof node.post === 'string' || !note.post) {
    return <Redirect to="/~404" />;
  }

  const remoteRef = useRef<typeof RemoteContent | null>(null);
  const index = node.post.index.split('/')[1];

  const markRead = useCallback(() => {
    api.hark.markEachAsRead(props.association, '/', `/${index}`, 'link', 'link');
  }, [association, index]);

  useEffect(() => {
    function onBlur() {
      // FF will only update on next tick
      setTimeout(() => {
        console.log(remoteRef.current);
        if(document.activeElement instanceof HTMLIFrameElement
          && remoteRef?.current?.containerRef?.contains(document.activeElement)) {
          markRead();
        }
      });
    }
    window.addEventListener('blur', onBlur);<commit_msg>interface: links should render even when a link is not deleted<commit_after>import { Action, Anchor, Box, Col, Icon, Row, Rule, Text } from '@tlon/indigo-react';
import { Association, GraphNode, Group } from '@urbit/api';
import React, { ReactElement, useCallback, useEffect, useRef } from 'react';
import { Link, Redirect } from 'react-router-dom';
import GlobalApi from '~/logic/api/global';
import { roleForShip } from '~/logic/lib/group';
import { getPermalinkForGraph, referenceToPermalink } from '~/logic/lib/permalinks';
import { useCopy } from '~/logic/lib/useCopy';
import useHarkState from '~/logic/state/hark';
import Author from '~/views/components/Author';
import { Dropdown } from '~/views/components/Dropdown';
import RemoteContent from '~/views/components/RemoteContent';
import { PermalinkEmbed } from '../../permalinks/embed';

interface LinkItemProps {
  node: GraphNode;
  association: Association;
  resource: string; api: GlobalApi; group: Group; path: string; }
export const LinkItem = React.forwardRef((props: LinkItemProps, ref): ReactElement => {
  const {
    association,
    node,
    resource,
    api,
    group,
    path,
    ...rest
  } = props;

  if (typeof node.post === 'string' || !node.post) {
    return <Redirect to="/~404" />;
  }

  const remoteRef = useRef<typeof RemoteContent | null>(null);
  const index = node.post.index.split('/')[1];

  const markRead = useCallback(() => {
    api.hark.markEachAsRead(props.association, '/', `/${index}`, 'link', 'link');
  }, [association, index]);

  useEffect(() => {
    function onBlur() {
      // FF will only update on next tick
      setTimeout(() => {
        console.log(remoteRef.current);
        if(document.activeElement instanceof HTMLIFrameElement
          && remoteRef?.current?.containerRef?.contains(document.activeElement)) {
          markRead();
        }
      });
    }
    window.addEventListener('blur', onBlur);
{'fraction_non_alphanumeric': 0.15293498289023427, 'fraction_numerical': 0.0021058173203474598, 'mean_word_length': 3.779874213836478, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '3832035', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1135, 'n_words': 291}