From b0c74a59bb26826994dcb27149992d0a800cf9a8 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 27 Nov 2025 15:59:00 -0500 Subject: [PATCH] ChatBarButtons: Fix Icons + Add AudioProcessor Def --- src/api/PluginManager.ts | 19 ++++++++--- src/equicordplugins/customSounds/index.tsx | 5 ++- src/equicordplugins/ingtoninator/index.tsx | 29 ++++++++++++---- .../invisibleChat.desktop/index.tsx | 34 ++++++++++++------- .../messageFetchTimer/index.tsx | 31 +++++++++++------ src/equicordplugins/sekaiStickers/index.tsx | 5 ++- src/equicordplugins/signature/index.tsx | 14 +++++++- src/equicordplugins/talkInReverse/index.tsx | 13 ++++++- src/plugins/silentTyping/index.tsx | 14 ++++++-- src/utils/types.ts | 4 +++ 10 files changed, 126 insertions(+), 42 deletions(-) diff --git a/src/api/PluginManager.ts b/src/api/PluginManager.ts index 2d57a4e59..9acfc94ee 100644 --- a/src/api/PluginManager.ts +++ b/src/api/PluginManager.ts @@ -40,6 +40,7 @@ import Plugins from "~plugins"; export { Plugins as plugins }; import { traceFunction } from "../debug/Tracer"; +import { addAudioProcessor, removeAudioProcessor } from "./AudioPlayer"; const logger = new Logger("PluginManager", "#a6d189"); @@ -187,7 +188,9 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p: const { name, commands, contextMenus, managedStyle, userProfileBadges, onBeforeMessageEdit, onBeforeMessageSend, onMessageClick, - renderChatBarButton, chatBarButton, renderMemberListDecorator, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton, messagePopoverButton, renderNicknameIcon + renderChatBarButton, chatBarButton, renderMemberListDecorator, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton, messagePopoverButton, + // Custom + renderNicknameIcon, audioProcessor } = p; if (p.start) { @@ -241,13 +244,16 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p: // @ts-expect-error: legacy code doesn't have icon else if (renderChatBarButton) addChatBarButton(name, renderChatBarButton); if (renderMemberListDecorator) addMemberListDecorator(name, renderMemberListDecorator); - if (renderNicknameIcon) addNicknameIcon(name, renderNicknameIcon); if (renderMessageDecoration) addMessageDecoration(name, renderMessageDecoration); if (renderMessageAccessory) addMessageAccessory(name, renderMessageAccessory); if (messagePopoverButton) addMessagePopoverButton(name, messagePopoverButton.render, messagePopoverButton.icon); // @ts-expect-error: legacy code doesn't have icon else if (renderMessagePopoverButton) addMessagePopoverButton(name, renderMessagePopoverButton); + // Custom + if (renderNicknameIcon) addNicknameIcon(name, renderNicknameIcon); + if (audioProcessor) addAudioProcessor(name, audioProcessor); + return true; }, p => `startPlugin ${p.name}`); @@ -255,7 +261,9 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu const { name, commands, contextMenus, managedStyle, userProfileBadges, onBeforeMessageEdit, onBeforeMessageSend, onMessageClick, - renderChatBarButton, chatBarButton, renderMemberListDecorator, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton, messagePopoverButton, renderNicknameIcon + renderChatBarButton, chatBarButton, renderMemberListDecorator, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton, messagePopoverButton, + // Custom + renderNicknameIcon, audioProcessor } = p; if (p.stop) { @@ -305,11 +313,14 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu if (chatBarButton || renderChatBarButton) removeChatBarButton(name); if (renderMemberListDecorator) removeMemberListDecorator(name); - if (renderNicknameIcon) removeNicknameIcon(name); if (renderMessageDecoration) removeMessageDecoration(name); if (renderMessageAccessory) removeMessageAccessory(name); if (messagePopoverButton || renderMessagePopoverButton) removeMessagePopoverButton(name); + // Custom + if (renderNicknameIcon) removeNicknameIcon(name); + if (audioProcessor) removeAudioProcessor(name); + return true; }, p => `stopPlugin ${p.name}`); diff --git a/src/equicordplugins/customSounds/index.tsx b/src/equicordplugins/customSounds/index.tsx index 0df8ae15c..ecdac9e7d 100644 --- a/src/equicordplugins/customSounds/index.tsx +++ b/src/equicordplugins/customSounds/index.tsx @@ -6,7 +6,7 @@ import "./styles.css"; -import { addAudioProcessor, AudioProcessor, PreprocessAudioData, removeAudioProcessor } from "@api/AudioPlayer"; +import { AudioProcessor, PreprocessAudioData } from "@api/AudioPlayer"; import { get as getFromDataStore } from "@api/DataStore"; import { definePluginSettings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; @@ -399,10 +399,10 @@ export default definePlugin({ settings, getCustomSoundURL, startAt: StartAt.Init, + audioProcessor: getCustomSoundURL, async start() { console.log("[CustomSounds] Plugin starting..."); - addAudioProcessor("CustomSounds", this.getCustomSoundURL); try { await preloadDataURIs(); @@ -413,7 +413,6 @@ export default definePlugin({ }, stop() { - removeAudioProcessor("CustomSounds"); console.log("[CustomSounds] Plugin stopped"); } }); diff --git a/src/equicordplugins/ingtoninator/index.tsx b/src/equicordplugins/ingtoninator/index.tsx index 0a777f340..83fc16875 100644 --- a/src/equicordplugins/ingtoninator/index.tsx +++ b/src/equicordplugins/ingtoninator/index.tsx @@ -79,24 +79,39 @@ const IngtoninatorButton: ChatBarButtonFactory = ({ isMainChat }) => { onClick={toggle} > {isEnabled ? ( - - - + enabledIcon() ) : ( - - - + disabledIcon() )} ); }; +function enabledIcon() { + return ( + + + + ); +} + +function disabledIcon() { + return ( + + + + ); +} + export default definePlugin({ name: "Ingtoninator", description: "Suffixes 'ington' to a random word in your message", authors: [EquicordDevs.zyqunix], settings, - renderChatBarButton: IngtoninatorButton, + chatBarButton: { + icon: disabledIcon, + render: IngtoninatorButton + }, start() { addMessagePreSendListener(handleMessage); }, diff --git a/src/equicordplugins/invisibleChat.desktop/index.tsx b/src/equicordplugins/invisibleChat.desktop/index.tsx index 37a14d4d2..4b3235534 100644 --- a/src/equicordplugins/invisibleChat.desktop/index.tsx +++ b/src/equicordplugins/invisibleChat.desktop/index.tsx @@ -65,7 +65,7 @@ function Indicator() { } -const ChatBarIcon: ChatBarButtonFactory = ({ isMainChat }) => { +const ChatBarRender: ChatBarButtonFactory = ({ isMainChat }) => { if (!isMainChat) return null; return ( @@ -76,20 +76,26 @@ const ChatBarIcon: ChatBarButtonFactory = ({ isMainChat }) => { "aria-haspopup": "dialog", }} > - - - + {ChatBarIcon()} ); }; +function ChatBarIcon() { + return ( + + + + ); +} + const settings = definePluginSettings({ savedPasswords: { type: OptionType.STRING, @@ -149,6 +155,11 @@ export default definePlugin({ reporterTestable: ReporterTestable.Patches, settings, + chatBarButton: { + icon: ChatBarIcon, + render: ChatBarRender + }, + patches: [ { // Indicator @@ -165,7 +176,6 @@ export default definePlugin({ const { default: StegCloak } = await getStegCloak(); steggo = new StegCloak(true, false); }, - renderChatBarButton: ChatBarIcon, messagePopoverButton: { icon: PopOverIcon, render(message) { diff --git a/src/equicordplugins/messageFetchTimer/index.tsx b/src/equicordplugins/messageFetchTimer/index.tsx index 40a6a7bff..93640440b 100644 --- a/src/equicordplugins/messageFetchTimer/index.tsx +++ b/src/equicordplugins/messageFetchTimer/index.tsx @@ -72,14 +72,7 @@ const FetchTimeButton: ChatBarButtonFactory = ({ isMainChat }) => { alignItems: "center", gap: "4px" }}> - - - + {FetchTimeIcon()} { ); }; +function FetchTimeIcon() { + return ( + + + + ); +} + function formatTimeAgo(timestamp: Date): string { const now = new Date(); const diff = now.getTime() - timestamp.getTime(); @@ -145,6 +151,11 @@ export default definePlugin({ authors: [EquicordDevs.GroupXyz], settings, + chatBarButton: { + icon: FetchTimeIcon, + render: FetchTimeButton + }, + start() { FluxDispatcher.subscribe("CHANNEL_SELECT", handleChannelSelect); FluxDispatcher.subscribe("LOAD_MESSAGES_SUCCESS", handleMessageLoad); @@ -164,7 +175,5 @@ export default definePlugin({ currentFetch = null; channelTimings.clear(); currentChannelId = null; - }, - - renderChatBarButton: FetchTimeButton, + } }); diff --git a/src/equicordplugins/sekaiStickers/index.tsx b/src/equicordplugins/sekaiStickers/index.tsx index bfbc07feb..08cc3058f 100644 --- a/src/equicordplugins/sekaiStickers/index.tsx +++ b/src/equicordplugins/sekaiStickers/index.tsx @@ -36,7 +36,10 @@ export default definePlugin({ authors: [Devs.MaiKokain], dependencies: ["ChatInputButtonAPI"], settings, - renderChatBarButton: SekaiStickerChatButton, + chatBarButton: { + icon: kanadeSvg, + render: SekaiStickerChatButton + }, async start() { const fonts = [{ name: "YurukaStd", url: "https://raw.githubusercontent.com/TheOriginalAyaka/sekai-stickers/47a2ca33b8cb35f59800e8faad48980e4ce5ea71/src/fonts/YurukaStd.woff2" }, { name: "SSFangTangTi", url: "https://raw.githubusercontent.com/TheOriginalAyaka/sekai-stickers/main/src/fonts/ShangShouFangTangTi.woff2" }]; if (!IS_FONTS_LOADED) { diff --git a/src/equicordplugins/signature/index.tsx b/src/equicordplugins/signature/index.tsx index 69d428d8f..5eb1d6b22 100644 --- a/src/equicordplugins/signature/index.tsx +++ b/src/equicordplugins/signature/index.tsx @@ -70,6 +70,14 @@ const SignatureToggle: ChatBarButtonFactory = ({ isMainChat }) => { ); }; +function SignatureIcon() { + return ( + + + + ); +} + const handleMessage = ((channelId, msg) => { if (!settings.store.isEnabled) { msg.content = msg.content; @@ -103,7 +111,6 @@ export default definePlugin({ description: "Automated fingerprint/end text", authors: [Devs.Ven, Devs.Rini, Devs.ImBanana, EquicordDevs.KrystalSkull], dependencies: ["MessageEventsAPI", "ChatInputButtonAPI"], - renderChatBarButton: SignatureToggle, start: () => { if (settings.store.isEnabled) true; @@ -115,6 +122,11 @@ export default definePlugin({ }, + chatBarButton: { + icon: SignatureIcon, + render: SignatureToggle + }, + settings, contextMenus: { diff --git a/src/equicordplugins/talkInReverse/index.tsx b/src/equicordplugins/talkInReverse/index.tsx index 7ecf97e5a..de5bc0477 100644 --- a/src/equicordplugins/talkInReverse/index.tsx +++ b/src/equicordplugins/talkInReverse/index.tsx @@ -54,10 +54,21 @@ const ReverseMessageToggle: ChatBarButtonFactory = ({ isMainChat }) => { ); }; +function ReverseMessageIcon() { + return ( + + + + ); +} + export default definePlugin({ name: "TalkInReverse", authors: [EquicordDevs.Tolgchu], description: "Reverses the message content before sending it.", dependencies: ["MessageEventsAPI", "ChatInputButtonAPI"], - renderChatBarButton: ReverseMessageToggle, + chatBarButton: { + icon: ReverseMessageIcon, + render: ReverseMessageToggle + } }); diff --git a/src/plugins/silentTyping/index.tsx b/src/plugins/silentTyping/index.tsx index c4b973ed1..4b0c41a8d 100644 --- a/src/plugins/silentTyping/index.tsx +++ b/src/plugins/silentTyping/index.tsx @@ -201,6 +201,14 @@ const SilentTypingChatToggle: ChatBarButtonFactory = ({ channel, type }) => { ); }; +function SilentTypingChatIcon() { + return ( + + + + ); +} + function getEffectiveList(): string[] { if (settings.store.defaultHidden) { if (!settings.store.disabledLocations) { @@ -298,6 +306,10 @@ export default definePlugin({ contextMenus: { "textarea-context": ChatBarContextCheckbox }, + chatBarButton: { + icon: SilentTypingChatIcon, + render: SilentTypingChatToggle + }, patches: [ { @@ -425,6 +437,4 @@ export default definePlugin({ if (checkEnabled(channelId)) return; FluxDispatcher.dispatch({ type: "TYPING_START_LOCAL", channelId }); }, - - renderChatBarButton: SilentTypingChatToggle, }); diff --git a/src/utils/types.ts b/src/utils/types.ts index d882dd785..a03ab10b5 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import { AudioProcessor } from "@api/AudioPlayer"; import type { ProfileBadge } from "@api/Badges"; import type { ChatBarButtonData, ChatBarButtonFactory } from "@api/ChatButtons"; import type { NavContextMenuPatchCallback } from "@api/ContextMenu"; @@ -195,7 +196,10 @@ export interface PluginDef { renderMessageDecoration?: MessageDecorationFactory; renderMemberListDecorator?: MemberListDecoratorFactory; + + // Custom renderNicknameIcon?: NicknameIconFactory; + audioProcessor?: AudioProcessor; // TODO: Remove eventually /**