Skip to content

Commit 487b454

Browse files
committed
fix: delete answers pnly show to author and admin and has searchparams aid
1 parent 3dee1c3 commit 487b454

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ui/src/pages/Questions/Detail/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const Index = () => {
5656
const { setUsers } = usePageUsers();
5757
const userInfo = loggedUserInfoStore((state) => state.user);
5858
const isAuthor = userInfo?.username === question?.user_info?.username;
59+
const isAdmin = userInfo?.is_admin;
5960
const isLogged = Boolean(userInfo?.access_token);
6061
const { state: locationState } = useLocation();
6162

@@ -76,6 +77,19 @@ const Index = () => {
7677
page_size: 999,
7778
});
7879
if (res) {
80+
res.list = res.list?.filter((v) => {
81+
// delete answers pnly show to author and admin and has searchparams aid
82+
if (v.status === 10) {
83+
if ((isAuthor || isAdmin) && aid === v.id) {
84+
return v;
85+
}
86+
return null;
87+
}
88+
89+
return v;
90+
});
91+
92+
console.log(res);
7993
setAnswers(res);
8094
if (page > 0 || order) {
8195
// scroll into view;

0 commit comments

Comments
 (0)