aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorV <vendicated@riseup.net>2023-05-23 01:55:39 +0200
committerGitHub <noreply@github.com>2023-05-23 01:55:39 +0200
commit184c03b28e6df72f301f91862dc8bdfb5f074fcb (patch)
treea543a4e3c932d172e76d86365b590265dfa1b0ff /src/components
parentec091a79591cf9619dd589102f5b338827b70ad8 (diff)
downloadVencord-184c03b28e6df72f301f91862dc8bdfb5f074fcb.tar.gz
Vencord-184c03b28e6df72f301f91862dc8bdfb5f074fcb.tar.bz2
Vencord-184c03b28e6df72f301f91862dc8bdfb5f074fcb.zip
PluginModal: Anonymise authors (#1176)
Diffstat (limited to 'src/components')
-rw-r--r--src/components/PluginSettings/PluginModal.tsx28
-rw-r--r--src/components/PluginSettings/userPopoutHideBotTag.css3
2 files changed, 25 insertions, 6 deletions
diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx
index 1818a8b..7079ebf 100644
--- a/src/components/PluginSettings/PluginModal.tsx
+++ b/src/components/PluginSettings/PluginModal.tsx
@@ -18,6 +18,7 @@
import { generateId } from "@api/Commands";
import { useSettings } from "@api/Settings";
+import { disableStyle, enableStyle } from "@api/Styles";
import ErrorBoundary from "@components/ErrorBoundary";
import { Flex } from "@components/Flex";
import { proxyLazy } from "@utils/lazy";
@@ -40,6 +41,7 @@ import {
SettingSliderComponent,
SettingTextComponent
} from "./components";
+import hideBotTagStyle from "./userPopoutHideBotTag.css?managed";
const UserSummaryItem = LazyComponent(() => findByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers"));
const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar");
@@ -50,11 +52,12 @@ interface PluginModalProps extends ModalProps {
onRestartNeeded(): void;
}
-/** To stop discord making unwanted requests... */
-function makeDummyUser(user: { name: string, id: BigInt; }) {
+function makeDummyUser(user: { username: string; id?: string; avatar?: string; }) {
const newUser = new UserRecord({
- username: user.name,
- id: generateId(),
+ username: user.username,
+ id: user.id ?? generateId(),
+ avatar: user.avatar,
+ /** To stop discord making unwanted requests... */
bot: true,
});
FluxDispatcher.dispatch({
@@ -89,14 +92,27 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
const hasSettings = Boolean(pluginSettings && plugin.options);
React.useEffect(() => {
+ enableStyle(hideBotTagStyle);
+
+ let originalUser: User;
(async () => {
for (const user of plugin.authors.slice(0, 6)) {
const author = user.id
- ? await UserUtils.fetchUser(`${user.id}`).catch(() => makeDummyUser(user))
- : makeDummyUser(user);
+ ? await UserUtils.fetchUser(`${user.id}`)
+ // only show name & pfp and no actions so users cannot harass plugin devs for support (send dms, add as friend, etc)
+ .then(u => (originalUser = u, makeDummyUser(u)))
+ .catch(() => makeDummyUser({ username: user.name }))
+ : makeDummyUser({ username: user.name });
+
setAuthors(a => [...a, author]);
}
})();
+
+ return () => {
+ disableStyle(hideBotTagStyle);
+ if (originalUser)
+ FluxDispatcher.dispatch({ type: "USER_UPDATE", user: originalUser });
+ };
}, []);
async function saveAndClose() {
diff --git a/src/components/PluginSettings/userPopoutHideBotTag.css b/src/components/PluginSettings/userPopoutHideBotTag.css
new file mode 100644
index 0000000..5e33e4b
--- /dev/null
+++ b/src/components/PluginSettings/userPopoutHideBotTag.css
@@ -0,0 +1,3 @@
+[class|="userPopoutOuter"] [class*="botTag"] {
+ display: none;
+}