From 487b45416577be35a36fdf9b1aa7a1030011e2f8 Mon Sep 17 00:00:00 2001 From: shuai Date: Mon, 6 Mar 2023 11:55:18 +0800 Subject: [PATCH 1/2] fix: delete answers pnly show to author and admin and has searchparams aid --- ui/src/pages/Questions/Detail/index.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ui/src/pages/Questions/Detail/index.tsx b/ui/src/pages/Questions/Detail/index.tsx index 289513c7..87c27caf 100644 --- a/ui/src/pages/Questions/Detail/index.tsx +++ b/ui/src/pages/Questions/Detail/index.tsx @@ -56,6 +56,7 @@ const Index = () => { const { setUsers } = usePageUsers(); const userInfo = loggedUserInfoStore((state) => state.user); const isAuthor = userInfo?.username === question?.user_info?.username; + const isAdmin = userInfo?.is_admin; const isLogged = Boolean(userInfo?.access_token); const { state: locationState } = useLocation(); @@ -76,6 +77,19 @@ const Index = () => { page_size: 999, }); if (res) { + res.list = res.list?.filter((v) => { + // delete answers pnly show to author and admin and has searchparams aid + if (v.status === 10) { + if ((isAuthor || isAdmin) && aid === v.id) { + return v; + } + return null; + } + + return v; + }); + + console.log(res); setAnswers(res); if (page > 0 || order) { // scroll into view; From 888e873a7c00bb481c9c99305610b6401c10a77a Mon Sep 17 00:00:00 2001 From: shuai Date: Mon, 6 Mar 2023 12:20:57 +0800 Subject: [PATCH 2/2] fix: answer the author's conditional judgement --- ui/src/pages/Questions/Detail/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/src/pages/Questions/Detail/index.tsx b/ui/src/pages/Questions/Detail/index.tsx index 87c27caf..610e3dcd 100644 --- a/ui/src/pages/Questions/Detail/index.tsx +++ b/ui/src/pages/Questions/Detail/index.tsx @@ -80,7 +80,10 @@ const Index = () => { res.list = res.list?.filter((v) => { // delete answers pnly show to author and admin and has searchparams aid if (v.status === 10) { - if ((isAuthor || isAdmin) && aid === v.id) { + if ( + (v?.user_info.username === userInfo?.username || isAdmin) && + aid === v.id + ) { return v; } return null;