From c27f596d4007dde3eff15c3eaee8ac21f633035c Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 12 Aug 2021 14:40:13 +0100 Subject: [PATCH] Show user flags and the bot owner. --- package.json | 2 +- .../popovers/UserProfile.module.scss | 54 ++++++++--------- .../intermediate/popovers/UserProfile.tsx | 58 ++++++++++++++++++- yarn.lock | 8 +-- 4 files changed, 89 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index ef118798..630bea65 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "react-virtuoso": "^1.10.4", "redux": "^4.1.0", "revolt-api": "^0.5.2-alpha.0", - "revolt.js": "5.0.1-alpha.0", + "revolt.js": "5.0.1-alpha.1", "rimraf": "^3.0.2", "sass": "^1.35.1", "shade-blend-color": "^1.0.0", diff --git a/src/context/intermediate/popovers/UserProfile.module.scss b/src/context/intermediate/popovers/UserProfile.module.scss index 51f7ca73..a45d71c3 100644 --- a/src/context/intermediate/popovers/UserProfile.module.scss +++ b/src/context/intermediate/popovers/UserProfile.module.scss @@ -136,34 +136,34 @@ a { min-width: 0; } +} - .entry { - gap: 8px; +.entry { + gap: 8px; + min-width: 0; + padding: 12px; + display: flex; + cursor: pointer; + align-items: center; + transition: background-color 0.1s; + color: var(--secondary-foreground); + border-radius: var(--border-radius); + background-color: var(--secondary-background); + + &:hover { + background-color: var(--primary-background); + } + + img { + width: 32px; + height: 32px; + border-radius: 50%; + } + + span { min-width: 0; - padding: 12px; - display: flex; - cursor: pointer; - align-items: center; - transition: background-color 0.1s; - color: var(--secondary-foreground); - border-radius: var(--border-radius); - background-color: var(--secondary-background); - - &:hover { - background-color: var(--primary-background); - } - - img { - width: 32px; - height: 32px; - border-radius: 50%; - } - - span { - min-width: 0; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; } } diff --git a/src/context/intermediate/popovers/UserProfile.tsx b/src/context/intermediate/popovers/UserProfile.tsx index 814460a3..12fd4e6d 100644 --- a/src/context/intermediate/popovers/UserProfile.tsx +++ b/src/context/intermediate/popovers/UserProfile.tsx @@ -13,9 +13,11 @@ import { useContext, useEffect, useLayoutEffect, useState } from "preact/hooks"; import ChannelIcon from "../../../components/common/ChannelIcon"; import Tooltip from "../../../components/common/Tooltip"; import UserIcon from "../../../components/common/user/UserIcon"; +import { Username } from "../../../components/common/user/UserShort"; import UserStatus from "../../../components/common/user/UserStatus"; import IconButton from "../../../components/ui/IconButton"; import Modal from "../../../components/ui/Modal"; +import Overline from "../../../components/ui/Overline"; import Preloader from "../../../components/ui/Preloader"; import Markdown from "../../../components/markdown/Markdown"; @@ -112,7 +114,9 @@ export const UserProfile = observer( const backgroundURL = profile && client.generateFileURL(profile.background, { width: 1000 }, true); + const badges = user.badges ?? 0; + const flags = user.flags ?? 0; return ( {tab === "profile" && (
- {!(profile?.content || badges > 0) && ( + {!( + profile?.content || + badges > 0 || + flags > 0 || + user.bot + ) && (
)} + {flags & 1 ? ( + /** ! FIXME: i18n this area */ + + User is suspended + + ) : undefined} + {flags & 2 ? ( + + User deleted their account + + ) : undefined} + {flags & 4 ? ( + + User is banned + + ) : undefined} + {user.bot ? ( + <> +
+ bot owner +
+
+ user.bot && + openScreen({ + id: "profile", + user_id: user.bot.owner, + }) + } + className={styles.entry} + key={user.bot.owner}> + + + + +
+ + ) : undefined} {badges > 0 && (
diff --git a/yarn.lock b/yarn.lock index af6d1d4c..a1dc21b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3605,10 +3605,10 @@ revolt-api@^0.5.2-alpha.0: resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.2-alpha.0.tgz#a41f44ee38622636c9b5b5843f9e2798a79f00d3" integrity sha512-VI/o4nQTPXrDCVdFpZFfZfj7Q4nunj62gftdmYJtuSmXx+6eN2Nve7QQZjNt6UIH6Dc/IDgiFDcBdafBF9YXug== -revolt.js@5.0.1-alpha.0: - version "5.0.1-alpha.0" - resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.1-alpha.0.tgz#3c79313ffe595ba5a4881692d5f3d2f5f6237bdb" - integrity sha512-fdYQgYA/aSx7JZn7yAwqb/8hix+nI/AErt6oAkb412qAyTFxHD7LHeUWofRMJ+I0rAreQUYUwtC5FJH82S58pQ== +revolt.js@5.0.1-alpha.1: + version "5.0.1-alpha.1" + resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.1-alpha.1.tgz#9af021d05d3cd098d0383c64e1fe10c70f2fb07a" + integrity sha512-QIbnR25ICey8iopMzu0FBueo7gd0ddZQVoyyC++jg4Rvt0zlcAHJfx/YTapZxzTFo0/u/YEgD68GuTh8ybmFdg== dependencies: axios "^0.19.2" eventemitter3 "^4.0.7"