aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNickyux <30734036+nmsturcke@users.noreply.github.com>2023-08-01 04:29:10 +0100
committerV <vendicated@riseup.net>2023-08-02 01:51:39 +0200
commitcc07518a34e62844fed57a408a6af1702e628200 (patch)
treedf82ffafccbeedc18acc2d2b3357172ab02cfbd0
parentea64b33e243e329fbbdd642df23e80cba848070f (diff)
downloadVencord-cc07518a34e62844fed57a408a6af1702e628200.tar.gz
Vencord-cc07518a34e62844fed57a408a6af1702e628200.tar.bz2
Vencord-cc07518a34e62844fed57a408a6af1702e628200.zip
VoiceMessages: Support replies (#1565)
Co-authored-by: TheKodeToad <TheKodeToad@proton.me> Co-authored-by: Justice Almanzar <superdash993@gmail.com> Co-authored-by: V <vendicated@riseup.net> Signed-off-by: V <vendicated@riseup.net>
-rw-r--r--src/plugins/voiceMessages/index.tsx14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/plugins/voiceMessages/index.tsx b/src/plugins/voiceMessages/index.tsx
index be5a3f3..b5b9c73 100644
--- a/src/plugins/voiceMessages/index.tsx
+++ b/src/plugins/voiceMessages/index.tsx
@@ -26,8 +26,8 @@ import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModa
import { useAwaiter } from "@utils/react";
import definePlugin from "@utils/types";
import { chooseFile } from "@utils/web";
-import { findLazy } from "@webpack";
-import { Button, Forms, Menu, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common";
+import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
+import { Button, FluxDispatcher, Forms, Menu, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common";
import { ComponentType } from "react";
import { VoiceRecorderDesktop } from "./DesktopRecorder";
@@ -37,6 +37,8 @@ import { VoicePreview } from "./VoicePreview";
import { VoiceRecorderWeb } from "./WebRecorder";
const CloudUpload = findLazy(m => m.prototype?.uploadFileToCloud);
+const MessageCreator = findByPropsLazy("getSendMessageOptionsForReply", "sendMessage");
+const PendingReplyStore = findStoreLazy("PendingReplyStore");
export type VoiceRecorder = ComponentType<{
setAudioBlob(blob: Blob): void;
@@ -48,7 +50,7 @@ const VoiceRecorder = IS_DISCORD_DESKTOP ? VoiceRecorderDesktop : VoiceRecorderW
export default definePlugin({
name: "VoiceMessages",
description: "Allows you to send voice messages like on mobile. To do so, right click the upload button and click Send Voice Message",
- authors: [Devs.Ven, Devs.Vap],
+ authors: [Devs.Ven, Devs.Vap, Devs.Nickyux],
settings,
start() {
@@ -71,6 +73,8 @@ const EMPTY_META: AudioMetadata = {
function sendAudio(blob: Blob, meta: AudioMetadata) {
const channelId = SelectedChannelStore.getChannelId();
+ const reply = PendingReplyStore.getPendingReply(channelId);
+ if (reply) FluxDispatcher.dispatch({ type: "DELETE_PENDING_REPLY", channelId });
const upload = new CloudUpload({
file: new File([blob], "voice-message.ogg", { type: "audio/ogg; codecs=opus" }),
@@ -95,7 +99,8 @@ function sendAudio(blob: Blob, meta: AudioMetadata) {
uploaded_filename: upload.uploadedFilename,
waveform: meta.waveform,
duration_secs: meta.duration,
- }]
+ }],
+ message_reference: reply ? MessageCreator.getSendMessageOptionsForReply(reply)?.messageReference : null,
}
});
});
@@ -232,4 +237,3 @@ const ctxMenuPatch: NavContextMenuPatchCallback = (children, props) => () => {
/>
);
};
-