feat(voiceMessages): respect silentMessageToggle (#158)

This commit is contained in:
Z1xus 2025-02-19 01:11:52 +01:00 committed by GitHub
parent ddf4d04cb9
commit a3d326db78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -25,6 +25,8 @@ import { React, useEffect, useState } from "@webpack/common";
let lastState = false; let lastState = false;
export { lastState };
const settings = definePluginSettings({ const settings = definePluginSettings({
persistState: { persistState: {
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,

View file

@ -21,7 +21,7 @@ import "./styles.css";
import { NavContextMenuPatchCallback } from "@api/ContextMenu"; import { NavContextMenuPatchCallback } from "@api/ContextMenu";
import { Microphone } from "@components/Icons"; import { Microphone } from "@components/Icons";
import { Link } from "@components/Link"; import { Link } from "@components/Link";
import { Devs } from "@utils/constants"; import { Devs, EquicordDevs } from "@utils/constants";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal"; import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal";
import { useAwaiter } from "@utils/react"; import { useAwaiter } from "@utils/react";
@ -30,6 +30,7 @@ import { chooseFile } from "@utils/web";
import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack"; import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
import { Button, Card, Constants, FluxDispatcher, Forms, lodash, Menu, MessageActions, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common"; import { Button, Card, Constants, FluxDispatcher, Forms, lodash, Menu, MessageActions, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common";
import { ComponentType } from "react"; import { ComponentType } from "react";
import { lastState as silentMessageEnabled } from "../silentMessageToggle";
import { VoiceRecorderDesktop } from "./DesktopRecorder"; import { VoiceRecorderDesktop } from "./DesktopRecorder";
import { settings } from "./settings"; import { settings } from "./settings";
@ -68,7 +69,7 @@ const ctxMenuPatch: NavContextMenuPatchCallback = (children, props) => {
export default definePlugin({ export default definePlugin({
name: "VoiceMessages", 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", 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, Devs.Nickyux], authors: [Devs.Ven, Devs.Vap, Devs.Nickyux, EquicordDevs.Z1xus],
settings, settings,
contextMenus: { contextMenus: {
"channel-attach": ctxMenuPatch "channel-attach": ctxMenuPatch
@ -99,7 +100,7 @@ function sendAudio(blob: Blob, meta: AudioMetadata) {
RestAPI.post({ RestAPI.post({
url: Constants.Endpoints.MESSAGES(channelId), url: Constants.Endpoints.MESSAGES(channelId),
body: { body: {
flags: 1 << 13, flags: (1 << 13) | (silentMessageEnabled ? 4096 : 0),
channel_id: channelId, channel_id: channelId,
content: "", content: "",
nonce: SnowflakeUtils.fromTimestamp(Date.now()), nonce: SnowflakeUtils.fromTimestamp(Date.now()),