From b01a3c5554f8b8b7064343f5bb9ae874c4932133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20L=C3=B6ffler?= Date: Tue, 17 Aug 2021 17:20:53 +0200 Subject: [PATCH] Hide reply mention button from current user --- .../common/messaging/bars/ReplyBar.tsx | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/src/components/common/messaging/bars/ReplyBar.tsx b/src/components/common/messaging/bars/ReplyBar.tsx index a327f161..a5c94ed2 100644 --- a/src/components/common/messaging/bars/ReplyBar.tsx +++ b/src/components/common/messaging/bars/ReplyBar.tsx @@ -14,6 +14,8 @@ import { getRenderer } from "../../../../lib/renderer/Singleton"; import { dispatch, getState } from "../../../../redux"; import { Reply } from "../../../../redux/reducers/queue"; +import { useClient } from "../../../../context/revoltjs/RevoltClient"; + import IconButton from "../../../ui/IconButton"; import Markdown from "../../../markdown/Markdown"; @@ -95,6 +97,7 @@ export default observer(({ channel, replies, setReplies }: Props) => { ); }, [replies, setReplies]); + const client = useClient(); const renderer = getRenderer(channel); if (renderer.state !== "RENDER") return null; @@ -153,34 +156,36 @@ export default observer(({ channel, replies, setReplies }: Props) => { - { - let state = false; - setReplies( - replies.map((_, i) => { - if (i === index) { - state = !_.mention; - return { - ..._, - mention: !_.mention, - }; - } + {message.author_id !== client.user!._id && ( + { + let state = false; + setReplies( + replies.map((_, i) => { + if (i === index) { + state = !_.mention; + return { + ..._, + mention: !_.mention, + }; + } - return _; - }), - ); + return _; + }), + ); - dispatch({ - type: "SECTION_TOGGLE_SET", - id: "mention", - state, - }); - }}> - - {" "} - {reply.mention ? "ON" : "OFF"} - - + dispatch({ + type: "SECTION_TOGGLE_SET", + id: "mention", + state, + }); + }}> + + {" "} + {reply.mention ? "ON" : "OFF"} + + + )} setReplies(