aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2023-04-18 23:12:58 +0200
committerVendicated <vendicated@riseup.net>2023-04-18 23:13:10 +0200
commit8dd70f5d1a5f0aee836d5633d504b75b6513bcc3 (patch)
treeadf91fbf4d6cd56e3a4d8900ed6aa0bafa54f0f7
parent8be6c6e3ceed26c5a4524784339c66d49cb1b278 (diff)
downloadVencord-8dd70f5d1a5f0aee836d5633d504b75b6513bcc3.tar.gz
Vencord-8dd70f5d1a5f0aee836d5633d504b75b6513bcc3.tar.bz2
Vencord-8dd70f5d1a5f0aee836d5633d504b75b6513bcc3.zip
Fix inserting text when markdown preview is off
-rw-r--r--src/plugins/gifPaste.ts4
-rw-r--r--src/plugins/invisibleChat/components/EncryptionModal.tsx7
-rw-r--r--src/plugins/quickMention.tsx5
-rw-r--r--src/plugins/sendTimestamps/index.tsx6
-rw-r--r--src/utils/discord.ts9
5 files changed, 19 insertions, 12 deletions
diff --git a/src/plugins/gifPaste.ts b/src/plugins/gifPaste.ts
index fa64f30..f1dfb2f 100644
--- a/src/plugins/gifPaste.ts
+++ b/src/plugins/gifPaste.ts
@@ -17,9 +17,9 @@
*/
import { Devs } from "@utils/constants";
+import { insertTextIntoChatInputBox } from "@utils/discord";
import definePlugin from "@utils/types";
import { filters, mapMangledModuleLazy } from "@webpack";
-import { ComponentDispatch } from "@webpack/common";
const ExpressionPickerState = mapMangledModuleLazy('name:"expression-picker-last-active-view"', {
close: filters.byCode("activeView:null", "setState")
@@ -40,7 +40,7 @@ export default definePlugin({
handleSelect(gif?: { url: string; }) {
if (gif) {
- ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", { rawText: gif.url + " " });
+ insertTextIntoChatInputBox(gif.url + " ");
ExpressionPickerState.close();
}
}
diff --git a/src/plugins/invisibleChat/components/EncryptionModal.tsx b/src/plugins/invisibleChat/components/EncryptionModal.tsx
index c4f1f35..570b4c0 100644
--- a/src/plugins/invisibleChat/components/EncryptionModal.tsx
+++ b/src/plugins/invisibleChat/components/EncryptionModal.tsx
@@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import { insertTextIntoChatInputBox } from "@utils/discord";
import {
ModalContent,
ModalFooter,
@@ -24,7 +25,7 @@ import {
ModalRoot,
openModal,
} from "@utils/modal";
-import { Button, ComponentDispatch, Forms, React, Switch, TextInput } from "@webpack/common";
+import { Button, Forms, React, Switch, TextInput } from "@webpack/common";
import { encrypt } from "../index";
@@ -84,9 +85,7 @@ function EncModal(props: ModalProps) {
const toSend = noCover ? encrypted.replaceAll("d", "") : encrypted;
if (!toSend) return;
- ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", {
- rawText: `${toSend}`
- });
+ insertTextIntoChatInputBox(toSend);
props.onClose();
}}
diff --git a/src/plugins/quickMention.tsx b/src/plugins/quickMention.tsx
index fe3da56..d0699b9 100644
--- a/src/plugins/quickMention.tsx
+++ b/src/plugins/quickMention.tsx
@@ -18,8 +18,9 @@
import { addButton, removeButton } from "@api/MessagePopover";
import { Devs } from "@utils/constants";
+import { insertTextIntoChatInputBox } from "@utils/discord";
import definePlugin from "@utils/types";
-import { ChannelStore, ComponentDispatch } from "@webpack/common";
+import { ChannelStore } from "@webpack/common";
export default definePlugin({
name: "QuickMention",
@@ -34,7 +35,7 @@ export default definePlugin({
icon: this.Icon,
message: msg,
channel: ChannelStore.getChannel(msg.channel_id),
- onClick: () => ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", { rawText: `<@${msg.author.id}> ` })
+ onClick: () => insertTextIntoChatInputBox(`<@${msg.author.id}> `)
};
});
},
diff --git a/src/plugins/sendTimestamps/index.tsx b/src/plugins/sendTimestamps/index.tsx
index 9eaa8be..f9d7cbe 100644
--- a/src/plugins/sendTimestamps/index.tsx
+++ b/src/plugins/sendTimestamps/index.tsx
@@ -21,11 +21,11 @@ import "./styles.css";
import { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
import { classNameFactory } from "@api/Styles";
import { Devs } from "@utils/constants";
-import { getTheme, Theme } from "@utils/discord";
+import { getTheme, insertTextIntoChatInputBox, Theme } from "@utils/discord";
import { Margins } from "@utils/margins";
import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal";
import definePlugin from "@utils/types";
-import { Button, ButtonLooks, ButtonWrapperClasses, ComponentDispatch, Forms, Parser, Select, Tooltip, useMemo, useState } from "@webpack/common";
+import { Button, ButtonLooks, ButtonWrapperClasses, Forms, Parser, Select, Tooltip, useMemo, useState } from "@webpack/common";
function parseTime(time: string) {
const cleanTime = time.slice(1, -1).replace(/(\d)(AM|PM)$/i, "$1 $2");
@@ -104,7 +104,7 @@ function PickerModal({ rootProps, close }: { rootProps: ModalProps, close(): voi
<ModalFooter>
<Button
onClick={() => {
- ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", { rawText: formatted });
+ insertTextIntoChatInputBox(formatted + " ");
close();
}}
>Insert</Button>
diff --git a/src/utils/discord.ts b/src/utils/discord.ts
index ec732b4..dfd20e6 100644
--- a/src/utils/discord.ts
+++ b/src/utils/discord.ts
@@ -17,7 +17,7 @@
*/
import { findLazy } from "@webpack";
-import { ChannelStore, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "@webpack/common";
+import { ChannelStore, ComponentDispatch, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "@webpack/common";
import { Guild } from "discord-types/general";
const PreloadedUserSettings = findLazy(m => m.ProtoClass?.typeName.endsWith("PreloadedUserSettings"));
@@ -42,3 +42,10 @@ export const enum Theme {
export function getTheme(): Theme {
return PreloadedUserSettings.getCurrentValue()?.appearance?.theme;
}
+
+export function insertTextIntoChatInputBox(text: string) {
+ ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", {
+ rawText: text,
+ plainText: text
+ });
+}