Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix(QuestionDetail): Compatible with `user_info` being null

haitaooa7d39a1c81d2
diff --git a/ui/src/pages/Questions/Detail/index.tsx b/ui/src/pages/Questions/Detail/index.tsx
index a6b3cc2d..b2e16812 100644
--- a/ui/src/pages/Questions/Detail/index.tsx
+++ b/ui/src/pages/Questions/Detail/index.tsx
@@ -81,7 +81,7 @@ const Index = () => {
// delete answers only show to author and admin and has search params aid
if (v.status === 10) {
if (
- (v?.user_info.username === userInfo?.username || isAdmin) &&
+ (v?.user_info?.username === userInfo?.username || isAdmin) &&
aid === v.id
) {
return v;
@@ -102,8 +102,8 @@ const Index = () => {
res.list.forEach((item) => {
setUsers([
{
- displayName: item.user_info.display_name,
- userName: item.user_info.username,
+ displayName: item.user_info?.display_name,
+ userName: item.user_info?.username,
},
{
displayName: item?.update_user_info?.display_name,
@@ -121,10 +121,10 @@ const Index = () => {
if (res) {
setUsers([
{
- id: res.user_info.id,
- displayName: res.user_info.display_name,
- userName: res.user_info.username,
- avatar_url: res.user_info.avatar,
+ id: res.user_info?.id,
+ displayName: res.user_info?.display_name,
+ userName: res.user_info?.username,
+ avatar_url: res.user_info?.avatar,
},
{
id: res?.update_user_info?.id,