|
@@ -20,7 +20,13 @@ const DiscussionTopicChildrenWidget = ({
|
|
|
const intl = useIntl();
|
|
const intl = useIntl();
|
|
|
const [data, setData] = useState<IComment[]>([]);
|
|
const [data, setData] = useState<IComment[]>([]);
|
|
|
const [loading, setLoading] = useState(true);
|
|
const [loading, setLoading] = useState(true);
|
|
|
-
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (loading === false) {
|
|
|
|
|
+ const ele = document.getElementById(`answer-${focus}`);
|
|
|
|
|
+ ele?.scrollIntoView();
|
|
|
|
|
+ console.log("after render");
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (typeof topicId === "undefined") {
|
|
if (typeof topicId === "undefined") {
|
|
|
return;
|
|
return;
|
|
@@ -29,9 +35,7 @@ const DiscussionTopicChildrenWidget = ({
|
|
|
|
|
|
|
|
get<ICommentListResponse>(`/v2/discussion?view=answer&id=${topicId}`)
|
|
get<ICommentListResponse>(`/v2/discussion?view=answer&id=${topicId}`)
|
|
|
.then((json) => {
|
|
.then((json) => {
|
|
|
- console.log(json);
|
|
|
|
|
if (json.ok) {
|
|
if (json.ok) {
|
|
|
- console.log("ok", json.data);
|
|
|
|
|
const discussions: IComment[] = json.data.rows.map((item) => {
|
|
const discussions: IComment[] = json.data.rows.map((item) => {
|
|
|
return {
|
|
return {
|
|
|
id: item.id,
|
|
id: item.id,
|
|
@@ -72,14 +76,12 @@ const DiscussionTopicChildrenWidget = ({
|
|
|
itemLayout="horizontal"
|
|
itemLayout="horizontal"
|
|
|
dataSource={data}
|
|
dataSource={data}
|
|
|
renderItem={(item) => {
|
|
renderItem={(item) => {
|
|
|
- console.log("focus", item.id, focus);
|
|
|
|
|
return (
|
|
return (
|
|
|
<List.Item>
|
|
<List.Item>
|
|
|
<DiscussionItem
|
|
<DiscussionItem
|
|
|
data={item}
|
|
data={item}
|
|
|
isFocus={item.id === focus ? true : false}
|
|
isFocus={item.id === focus ? true : false}
|
|
|
onDelete={() => {
|
|
onDelete={() => {
|
|
|
- console.log("delete", item.id, data);
|
|
|
|
|
if (typeof onItemCountChange !== "undefined") {
|
|
if (typeof onItemCountChange !== "undefined") {
|
|
|
onItemCountChange(data.length - 1, item.parent);
|
|
onItemCountChange(data.length - 1, item.parent);
|
|
|
}
|
|
}
|
|
@@ -97,7 +99,6 @@ const DiscussionTopicChildrenWidget = ({
|
|
|
contentType="markdown"
|
|
contentType="markdown"
|
|
|
parent={topicId}
|
|
parent={topicId}
|
|
|
onCreated={(e: IComment) => {
|
|
onCreated={(e: IComment) => {
|
|
|
- console.log("create", e);
|
|
|
|
|
const newData = JSON.parse(JSON.stringify(e));
|
|
const newData = JSON.parse(JSON.stringify(e));
|
|
|
setData([...data, newData]);
|
|
setData([...data, newData]);
|
|
|
if (typeof onItemCountChange !== "undefined") {
|
|
if (typeof onItemCountChange !== "undefined") {
|