Skip to content

Commit fe88a7a

Browse files
authored
Merge pull request #496 from TianyangRen/main
Fix row height inconsistency on friends page (#495)
2 parents 92101bf + 1ddbb96 commit fe88a7a

File tree

1 file changed

+49
-48
lines changed

1 file changed

+49
-48
lines changed

src/components/friends/FriendListRow.tsx

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -64,56 +64,57 @@ export const FriendListRow = ({
6464
)}
6565
</TableTd>
6666
<TableTd style={{ textAlign: "right", padding: "7px 0px" }}>
67-
{!isMe && (
68-
<Button
69-
variant="outline"
70-
color="red"
71-
size="compact-md"
72-
loading={isDeleting}
73-
onClick={() => {
74-
setIsDeleting(true);
75-
removeFriend(username)
76-
.then(async (result) => {
77-
if (result && "error" in result) {
78-
switch (result.error) {
79-
case RemoveFriendError.RateLimited:
80-
router.push("/rate-limited");
81-
break;
82-
case RemoveFriendError.Unauthorized:
83-
showNotification({
84-
title: t("error"),
85-
color: "red",
86-
message: t("errors.unauthorized"),
87-
});
88-
await logOutAndRedirect();
89-
break;
90-
case RemoveFriendError.UnknownError:
91-
showNotification({
92-
title: t("error"),
93-
color: "red",
94-
message: t("friends.errorRemovingFriend"),
95-
});
96-
break;
97-
}
98-
} else {
99-
router.refresh();
67+
<Button
68+
variant="outline"
69+
size="compact-md"
70+
color="red"
71+
loading={isDeleting}
72+
// Keep button space consistent across rows; hide for self to match row height
73+
style={{ visibility: isMe ? "hidden" : undefined }}
74+
aria-hidden={isMe ? "true" : undefined}
75+
onClick={() => {
76+
setIsDeleting(true);
77+
removeFriend(username)
78+
.then(async (result) => {
79+
if (result && "error" in result) {
80+
switch (result.error) {
81+
case RemoveFriendError.RateLimited:
82+
router.push("/rate-limited");
83+
break;
84+
case RemoveFriendError.Unauthorized:
85+
showNotification({
86+
title: t("error"),
87+
color: "red",
88+
message: t("errors.unauthorized"),
89+
});
90+
await logOutAndRedirect();
91+
break;
92+
case RemoveFriendError.UnknownError:
93+
showNotification({
94+
title: t("error"),
95+
color: "red",
96+
message: t("friends.errorRemovingFriend"),
97+
});
98+
break;
10099
}
101-
})
102-
.catch(() => {
103-
showNotification({
104-
title: t("error"),
105-
color: "red",
106-
message: t("friends.errorRemovingFriend"),
107-
});
108-
})
109-
.finally(() => {
110-
setIsDeleting(false);
100+
} else {
101+
router.refresh();
102+
}
103+
})
104+
.catch(() => {
105+
showNotification({
106+
title: t("error"),
107+
color: "red",
108+
message: t("friends.errorRemovingFriend"),
111109
});
112-
}}
113-
>
114-
{t("friends.unfriend")}
115-
</Button>
116-
)}
110+
})
111+
.finally(() => {
112+
setIsDeleting(false);
113+
});
114+
}}
115+
>
116+
{t("friends.unfriend")}
117+
</Button>
117118
</TableTd>
118119
</TableTr>
119120
);

0 commit comments

Comments
 (0)