From 0729e5c052dceca39e227b14536f2a26580a1bf9 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 8 Apr 2019 17:36:56 +0300 Subject: embeds in Thread --- vnext/src/components/Thread.js | 99 +++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 41 deletions(-) (limited to 'vnext/src') diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js index c1dc915b..3fa0ce10 100644 --- a/vnext/src/components/Thread.js +++ b/vnext/src/components/Thread.js @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState, useRef } from 'react'; import ReactRouterPropTypes from 'react-router-prop-types'; import { UserType } from './Types'; @@ -12,10 +12,65 @@ import Spinner from './Spinner'; import Avatar from './Avatar'; import Button from './Button'; -import { format } from '../utils/embed'; +import { format, embedUrls } from '../utils/embed'; import { getMessages, comment, markReadTracker } from '../api'; +function Comment({ msg, visitor, active, setActive }) { + const embedRef = useRef(); + const msgRef = useRef(); + useEffect(() => { + if (msgRef.current) { + embedUrls(msgRef.current.querySelectorAll('a'), embedRef.current); + if (!embedRef.current.hasChildNodes()) { + embedRef.current.style.display = 'none'; + } + } + }, []); + return ( +
= 0) }} /> +
+ +
+ } + += 0) }} /> -
- -
- } -