mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-29 02:10:59 -05:00
fix: let users message/hide mutuals tab for bots
This commit is contained in:
parent
099f7a3116
commit
e53059ee08
3 changed files with 29 additions and 25 deletions
|
@ -41,8 +41,8 @@ import { ModalProps } from "../../types";
|
||||||
export const UserProfile = observer(
|
export const UserProfile = observer(
|
||||||
({
|
({
|
||||||
user_id,
|
user_id,
|
||||||
dummy,
|
isPlaceholder,
|
||||||
dummyProfile,
|
placeholderProfile,
|
||||||
...props
|
...props
|
||||||
}: ModalProps<"user_profile">) => {
|
}: ModalProps<"user_profile">) => {
|
||||||
const [profile, setProfile] = useState<
|
const [profile, setProfile] = useState<
|
||||||
|
@ -87,21 +87,21 @@ export const UserProfile = observer(
|
||||||
}, [user_id]);
|
}, [user_id]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dummy) {
|
if (isPlaceholder) {
|
||||||
setProfile(dummyProfile);
|
setProfile(placeholderProfile);
|
||||||
}
|
}
|
||||||
}, [dummy, dummyProfile]);
|
}, [isPlaceholder, placeholderProfile]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dummy) return;
|
if (isPlaceholder) return;
|
||||||
if (session.state === "Online" && typeof mutual === "undefined") {
|
if (session.state === "Online" && typeof mutual === "undefined") {
|
||||||
setMutual(null);
|
setMutual(null);
|
||||||
user.fetchMutual().then(setMutual);
|
user.fetchMutual().then(setMutual);
|
||||||
}
|
}
|
||||||
}, [mutual, session.state, dummy, user]);
|
}, [mutual, session.state, isPlaceholder, user]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dummy) return;
|
if (isPlaceholder) return;
|
||||||
if (session.state === "Online" && typeof profile === "undefined") {
|
if (session.state === "Online" && typeof profile === "undefined") {
|
||||||
setProfile(null);
|
setProfile(null);
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ export const UserProfile = observer(
|
||||||
user.fetchProfile().then(setProfile).catch(noop);
|
user.fetchProfile().then(setProfile).catch(noop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [profile, session.state, dummy, user]);
|
}, [profile, session.state, isPlaceholder, user]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
|
@ -169,7 +169,8 @@ export const UserProfile = observer(
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
modalController.writeText(user.username)
|
modalController.writeText(user.username)
|
||||||
}>
|
}>
|
||||||
@{user.username}
|
{"@"}
|
||||||
|
{user.username}
|
||||||
</span>
|
</span>
|
||||||
</Localizer>
|
</Localizer>
|
||||||
{user.status?.text && (
|
{user.status?.text && (
|
||||||
|
@ -184,11 +185,11 @@ export const UserProfile = observer(
|
||||||
palette="accent"
|
palette="accent"
|
||||||
compact
|
compact
|
||||||
onClick={props.onClose}>
|
onClick={props.onClose}>
|
||||||
Add to server
|
{"Add to server" /* FIXME: i18n */}
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
{user.relationship === "Friend" && (
|
{(user.relationship === "Friend" || user.bot) && (
|
||||||
<Localizer>
|
<Localizer>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={
|
content={
|
||||||
|
@ -204,7 +205,7 @@ export const UserProfile = observer(
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Localizer>
|
</Localizer>
|
||||||
)}
|
)}
|
||||||
{user.relationship === "User" && !dummy && (
|
{user.relationship === "User" && !isPlaceholder && (
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
props.onClose?.();
|
props.onClose?.();
|
||||||
|
@ -237,11 +238,13 @@ export const UserProfile = observer(
|
||||||
</div>
|
</div>
|
||||||
{user.relationship !== "User" && (
|
{user.relationship !== "User" && (
|
||||||
<>
|
<>
|
||||||
|
{!user.bot && (
|
||||||
<div
|
<div
|
||||||
data-active={tab === "friends"}
|
data-active={tab === "friends"}
|
||||||
onClick={() => setTab("friends")}>
|
onClick={() => setTab("friends")}>
|
||||||
<Text id="app.special.popovers.user_profile.mutual_friends" />
|
<Text id="app.special.popovers.user_profile.mutual_friends" />
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
<div
|
<div
|
||||||
data-active={tab === "groups"}
|
data-active={tab === "groups"}
|
||||||
onClick={() => setTab("groups")}>
|
onClick={() => setTab("groups")}>
|
||||||
|
@ -281,8 +284,9 @@ export const UserProfile = observer(
|
||||||
) : undefined}
|
) : undefined}
|
||||||
{user.bot ? (
|
{user.bot ? (
|
||||||
<>
|
<>
|
||||||
|
{/* FIXME: this too */}
|
||||||
<div className={styles.category}>
|
<div className={styles.category}>
|
||||||
bot owner
|
{"bot owner"}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
|
@ -432,12 +436,12 @@ export const UserProfile = observer(
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (dummy) return <div>{children}</div>;
|
if (isPlaceholder) return <div>{children}</div>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
{...props}
|
{...props}
|
||||||
nonDismissable={dummy}
|
nonDismissable={isPlaceholder}
|
||||||
transparent
|
transparent
|
||||||
maxWidth="560px">
|
maxWidth="560px">
|
||||||
{children}
|
{children}
|
||||||
|
|
|
@ -98,8 +98,8 @@ export type Modal = {
|
||||||
| {
|
| {
|
||||||
type: "user_profile";
|
type: "user_profile";
|
||||||
user_id: string;
|
user_id: string;
|
||||||
dummy?: boolean;
|
isPlaceholder?: boolean;
|
||||||
dummyProfile?: API.UserProfile;
|
placeholderProfile?: API.UserProfile;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: "create_bot";
|
type: "create_bot";
|
||||||
|
|
|
@ -72,8 +72,8 @@ export const Profile = observer(() => {
|
||||||
<div className={styles.preview}>
|
<div className={styles.preview}>
|
||||||
<UserProfile
|
<UserProfile
|
||||||
user_id={client.user!._id}
|
user_id={client.user!._id}
|
||||||
dummy={true}
|
isPlaceholder={true}
|
||||||
dummyProfile={profile}
|
placeholderProfile={profile}
|
||||||
{...({} as any)}
|
{...({} as any)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue