From 1237687e07e0044795c889d994c638f8d9372fef Mon Sep 17 00:00:00 2001 From: Inbestigator Date: Sun, 3 Mar 2024 18:05:30 -0800 Subject: [PATCH] Made join button unspammable --- src/plugins/encryptcord/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/encryptcord/index.tsx b/src/plugins/encryptcord/index.tsx index a308f7b82..fcaadcb4d 100644 --- a/src/plugins/encryptcord/index.tsx +++ b/src/plugins/encryptcord/index.tsx @@ -41,6 +41,7 @@ interface IMessageCreate { // Chat Bar Icon Component const ChatBarIcon: ChatBarButton = ({ isMainChat }) => { [enabled, setEnabled] = useState(false); + let [buttonDisabled, setButtonDisabled] = useState(false); useEffect(() => { const listener: SendListener = async (_, message) => { @@ -78,6 +79,7 @@ const ChatBarIcon: ChatBarButton = ({ isMainChat }) => { tooltip={enabled ? "Send Unencrypted Messages" : "Send Encrypted Messages"} onClick={async () => { if (await DataStore.get('encryptcordGroup') == false || (await DataStore.get('encryptcordChannelId') != getCurrentChannel().id)) { + setButtonDisabled(true); await sendTempMessage(getCurrentChannel().id, "", `join\`\`\`\n${await DataStore.get("encryptcordPublicKey")}\`\`\``, false); sendBotMessage(getCurrentChannel().id, { content: `*Checking for any groups in this channel...*\n> If none is found, a new one will be created ` }); await sleep(5000); @@ -90,12 +92,14 @@ const ChatBarIcon: ChatBarButton = ({ isMainChat }) => { await startGroup("", { channel: { id: getCurrentChannel().id } }); } setEnabled(!enabled); + setButtonDisabled(false); }} buttonProps={{ style: { transition: 'transform 0.3s ease-in-out', transform: `rotate(${enabled ? 0 : 15}deg)`, - } + }, + disabled: buttonDisabled }} >