fix getCommentMediaInfo

This commit is contained in:
plebbitor
2023-04-14 15:59:57 +02:00
parent 2a0bf0eec6
commit 2b72ec6841
4 changed files with 73 additions and 19 deletions
+11 -3
View File
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import { Tooltip } from 'react-tooltip';
import useGeneralStore from '../../hooks/stores/useGeneralStore';
@@ -36,10 +36,9 @@ const Pending = () => {
useError(errorMessage, [errorMessage]);
useSuccess(successMessage, [successMessage]);
const navigate = useNavigate();
const commentMediaInfo = getCommentMediaInfo(comment);
const [commentMediaInfo, setCommentMediaInfo] = useState(null);
const fallbackImgUrl = "/assets/filedeleted-res.gif";
// mobile navbar board select functionality
const handleSelectChange = (event) => {
const selected = event.target.value;
@@ -49,6 +48,15 @@ const Pending = () => {
navigate(`/p/${selected}`);
};
// get comment media info
useEffect(() => {
if (comment && comment.link) {
const mediaInfo = getCommentMediaInfo(comment);
setCommentMediaInfo(mediaInfo);
}
}, [comment]);
return (
<Container>
<SettingsModal