Hide reply mention button from current user

This commit is contained in:
Martin Löffler 2021-08-17 17:20:53 +02:00
parent ca6bdd332e
commit b01a3c5554
No known key found for this signature in database
GPG key ID: FFEF368AC076566A

View file

@ -14,6 +14,8 @@ import { getRenderer } from "../../../../lib/renderer/Singleton";
import { dispatch, getState } from "../../../../redux"; import { dispatch, getState } from "../../../../redux";
import { Reply } from "../../../../redux/reducers/queue"; import { Reply } from "../../../../redux/reducers/queue";
import { useClient } from "../../../../context/revoltjs/RevoltClient";
import IconButton from "../../../ui/IconButton"; import IconButton from "../../../ui/IconButton";
import Markdown from "../../../markdown/Markdown"; import Markdown from "../../../markdown/Markdown";
@ -95,6 +97,7 @@ export default observer(({ channel, replies, setReplies }: Props) => {
); );
}, [replies, setReplies]); }, [replies, setReplies]);
const client = useClient();
const renderer = getRenderer(channel); const renderer = getRenderer(channel);
if (renderer.state !== "RENDER") return null; if (renderer.state !== "RENDER") return null;
@ -153,34 +156,36 @@ export default observer(({ channel, replies, setReplies }: Props) => {
</div> </div>
</ReplyBase> </ReplyBase>
<span class="actions"> <span class="actions">
<IconButton {message.author_id !== client.user!._id && (
onClick={() => { <IconButton
let state = false; onClick={() => {
setReplies( let state = false;
replies.map((_, i) => { setReplies(
if (i === index) { replies.map((_, i) => {
state = !_.mention; if (i === index) {
return { state = !_.mention;
..._, return {
mention: !_.mention, ..._,
}; mention: !_.mention,
} };
}
return _; return _;
}), }),
); );
dispatch({ dispatch({
type: "SECTION_TOGGLE_SET", type: "SECTION_TOGGLE_SET",
id: "mention", id: "mention",
state, state,
}); });
}}> }}>
<span class="toggle"> <span class="toggle">
<At size={16} />{" "} <At size={16} />{" "}
{reply.mention ? "ON" : "OFF"} {reply.mention ? "ON" : "OFF"}
</span> </span>
</IconButton> </IconButton>
)}
<IconButton <IconButton
onClick={() => onClick={() =>
setReplies( setReplies(