1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-09 09:26:22 +00:00

rename API methods to have more informative names

This commit is contained in:
Vendicated 2024-11-21 03:57:17 +01:00
parent cff2c53972
commit f6803d0c55
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
12 changed files with 48 additions and 48 deletions

View file

@ -57,7 +57,7 @@ const Badges = new Set<ProfileBadge>();
* Register a new badge with the Badges API
* @param badge The badge to register
*/
export function addBadge(badge: ProfileBadge) {
export function addProfileBadge(badge: ProfileBadge) {
badge.component &&= ErrorBoundary.wrap(badge.component, { noop: true });
Badges.add(badge);
}
@ -66,7 +66,7 @@ export function addBadge(badge: ProfileBadge) {
* Unregister a badge from the Badges API
* @param badge The badge to remove
*/
export function removeBadge(badge: ProfileBadge) {
export function removeProfileBadge(badge: ProfileBadge) {
return Badges.delete(badge);
}

View file

@ -43,11 +43,11 @@ type OnlyIn = "guilds" | "dms";
export const decorators = new Map<string, { decorator: MemberListDecoratorFactory, onlyIn?: OnlyIn; }>();
export function addDecorator(identifier: string, decorator: MemberListDecoratorFactory, onlyIn?: OnlyIn) {
export function addMemberListDecorator(identifier: string, decorator: MemberListDecoratorFactory, onlyIn?: OnlyIn) {
decorators.set(identifier, { decorator, onlyIn });
}
export function removeDecorator(identifier: string) {
export function removeMemberListDecorator(identifier: string) {
decorators.delete(identifier);
}

View file

@ -24,7 +24,7 @@ export type MessageAccessory = {
export const accessories = new Map<String, MessageAccessory>();
export function addAccessory(
export function addMessageAccessory(
identifier: string,
callback: MessageAccessoryFactory,
position?: number
@ -35,7 +35,7 @@ export function addAccessory(
});
}
export function removeAccessory(identifier: string) {
export function removeMessageAccessory(identifier: string) {
accessories.delete(identifier);
}

View file

@ -48,11 +48,11 @@ export type MessageDecorationFactory = (props: MessageDecorationProps) => JSX.El
export const decorations = new Map<string, MessageDecorationFactory>();
export function addDecoration(identifier: string, decoration: MessageDecorationFactory) {
export function addMessageDecoration(identifier: string, decoration: MessageDecorationFactory) {
decorations.set(identifier, decoration);
}
export function removeDecoration(identifier: string) {
export function removeMessageDecoration(identifier: string) {
decorations.delete(identifier);
}

View file

@ -147,11 +147,11 @@ export function _handleClick(message: Message, channel: Channel, event: MouseEve
}
}
export function addClickListener(listener: MessageClickListener) {
export function addMessageClickListener(listener: MessageClickListener) {
listeners.add(listener);
return listener;
}
export function removeClickListener(listener: MessageClickListener) {
export function removeMessageClickListener(listener: MessageClickListener) {
return listeners.delete(listener);
}

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { addAccessory } from "@api/MessageAccessories";
import { addMessageAccessory } from "@api/MessageAccessories";
import { definePluginSettings } from "@api/Settings";
import { getUserSettingLazy } from "@api/UserSettings";
import ErrorBoundary from "@components/ErrorBoundary";
@ -251,7 +251,7 @@ export default definePlugin({
}, { noop: true }),
start() {
addAccessory("vencord-debug", props => {
addMessageAccessory("vencord-debug", props => {
const buttons = [] as JSX.Element[];
const shouldAddUpdateButton =

View file

@ -19,10 +19,10 @@
import { addChatBarButton, removeChatBarButton } from "@api/ChatButtons";
import { registerCommand, unregisterCommand } from "@api/Commands";
import { addContextMenuPatch, removeContextMenuPatch } from "@api/ContextMenu";
import { addDecorator, removeDecorator } from "@api/MemberListDecorators";
import { addAccessory, removeAccessory } from "@api/MessageAccessories";
import { addDecoration, removeDecoration } from "@api/MessageDecorations";
import { addClickListener, addPreEditListener, addPreSendListener, removeClickListener, removePreEditListener, removePreSendListener } from "@api/MessageEvents";
import { addMemberListDecorator, removeMemberListDecorator } from "@api/MemberListDecorators";
import { addMessageAccessory, removeMessageAccessory } from "@api/MessageAccessories";
import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";
import { addMessageClickListener, addPreEditListener, addPreSendListener, removeMessageClickListener, removePreEditListener, removePreSendListener } from "@api/MessageEvents";
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
import { Settings } from "@api/Settings";
import { Logger } from "@utils/Logger";
@ -279,12 +279,12 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p:
if (onBeforeMessageEdit) addPreEditListener(onBeforeMessageEdit);
if (onBeforeMessageSend) addPreSendListener(onBeforeMessageSend);
if (onMessageClick) addClickListener(onMessageClick);
if (onMessageClick) addMessageClickListener(onMessageClick);
if (renderChatBarButton) addChatBarButton(name, renderChatBarButton);
if (renderMemberListDecorator) addDecorator(name, renderMemberListDecorator);
if (renderMessageDecoration) addDecoration(name, renderMessageDecoration);
if (renderMessageAccessory) addAccessory(name, renderMessageAccessory);
if (renderMemberListDecorator) addMemberListDecorator(name, renderMemberListDecorator);
if (renderMessageDecoration) addMessageDecoration(name, renderMessageDecoration);
if (renderMessageAccessory) addMessageAccessory(name, renderMessageAccessory);
if (renderMessagePopoverButton) addMessagePopoverButton(name, renderMessagePopoverButton);
return true;
@ -336,12 +336,12 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu
if (onBeforeMessageEdit) removePreEditListener(onBeforeMessageEdit);
if (onBeforeMessageSend) removePreSendListener(onBeforeMessageSend);
if (onMessageClick) removeClickListener(onMessageClick);
if (onMessageClick) removeMessageClickListener(onMessageClick);
if (renderChatBarButton) removeChatBarButton(name);
if (renderMemberListDecorator) removeDecorator(name);
if (renderMessageDecoration) removeDecoration(name);
if (renderMessageAccessory) removeAccessory(name);
if (renderMemberListDecorator) removeMemberListDecorator(name);
if (renderMessageDecoration) removeMessageDecoration(name);
if (renderMessageAccessory) removeMessageAccessory(name);
if (renderMessagePopoverButton) removeMessagePopoverButton(name);
return true;

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { addClickListener, removeClickListener } from "@api/MessageEvents";
import { addMessageClickListener, removeMessageClickListener } from "@api/MessageEvents";
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
@ -65,7 +65,7 @@ export default definePlugin({
document.addEventListener("keydown", keydown);
document.addEventListener("keyup", keyup);
this.onClick = addClickListener((msg: any, channel, event) => {
this.onClick = addMessageClickListener((msg: any, channel, event) => {
const isMe = msg.author.id === UserStore.getCurrentUser().id;
if (!isDeletePressed) {
if (event.detail < 2) return;
@ -115,7 +115,7 @@ export default definePlugin({
},
stop() {
removeClickListener(this.onClick);
removeMessageClickListener(this.onClick);
document.removeEventListener("keydown", keydown);
document.removeEventListener("keyup", keyup);
}

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { addAccessory, removeAccessory } from "@api/MessageAccessories";
import { addMessageAccessory, removeMessageAccessory } from "@api/MessageAccessories";
import { updateMessage } from "@api/MessageUpdater";
import { definePluginSettings } from "@api/Settings";
import { getUserSettingLazy } from "@api/UserSettings";
@ -372,7 +372,7 @@ export default definePlugin({
settings,
start() {
addAccessory("messageLinkEmbed", props => {
addMessageAccessory("messageLinkEmbed", props => {
if (!messageLinkRegex.test(props.message.content))
return null;
@ -390,6 +390,6 @@ export default definePlugin({
},
stop() {
removeAccessory("messageLinkEmbed");
removeMessageAccessory("messageLinkEmbed");
}
});

View file

@ -18,9 +18,9 @@
import "./style.css";
import { addBadge, BadgePosition, BadgeUserArgs, ProfileBadge, removeBadge } from "@api/Badges";
import { addDecorator, removeDecorator } from "@api/MemberListDecorators";
import { addDecoration, removeDecoration } from "@api/MessageDecorations";
import { addProfileBadge, BadgePosition, BadgeUserArgs, ProfileBadge, removeProfileBadge } from "@api/Badges";
import { addMemberListDecorator, removeMemberListDecorator } from "@api/MemberListDecorators";
import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";
import { Settings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
@ -172,26 +172,26 @@ const badge: ProfileBadge = {
const indicatorLocations = {
list: {
description: "In the member list",
onEnable: () => addDecorator("platform-indicator", props =>
onEnable: () => addMemberListDecorator("platform-indicator", props =>
<ErrorBoundary noop>
<PlatformIndicator user={props.user} small={true} />
</ErrorBoundary>
),
onDisable: () => removeDecorator("platform-indicator")
onDisable: () => removeMemberListDecorator("platform-indicator")
},
badges: {
description: "In user profiles, as badges",
onEnable: () => addBadge(badge),
onDisable: () => removeBadge(badge)
onEnable: () => addProfileBadge(badge),
onDisable: () => removeProfileBadge(badge)
},
messages: {
description: "Inside messages",
onEnable: () => addDecoration("platform-indicator", props =>
onEnable: () => addMessageDecoration("platform-indicator", props =>
<ErrorBoundary noop>
<PlatformIndicator user={props.message?.author} wantTopMargin={true} />
</ErrorBoundary>
),
onDisable: () => removeDecoration("platform-indicator")
onDisable: () => removeMessageDecoration("platform-indicator")
}
};

View file

@ -20,7 +20,7 @@ import "./styles.css";
import { addChatBarButton, removeChatBarButton } from "@api/ChatButtons";
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
import { addAccessory, removeAccessory } from "@api/MessageAccessories";
import { addMessageAccessory, removeMessageAccessory } from "@api/MessageAccessories";
import { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
import { Devs } from "@utils/constants";
@ -64,7 +64,7 @@ export default definePlugin({
translate,
start() {
addAccessory("vc-translation", props => <TranslationAccessory message={props.message} />);
addMessageAccessory("vc-translation", props => <TranslationAccessory message={props.message} />);
addChatBarButton("vc-translate", TranslateChatBarIcon);
@ -102,6 +102,6 @@ export default definePlugin({
removePreSendListener(this.preSend);
removeChatBarButton("vc-translate");
removeMessagePopoverButton("vc-translate");
removeAccessory("vc-translation");
removeMessageAccessory("vc-translation");
},
});

View file

@ -18,8 +18,8 @@
import "./style.css";
import { addDecorator, removeDecorator } from "@api/MemberListDecorators";
import { addDecoration, removeDecoration } from "@api/MessageDecorations";
import { addMemberListDecorator, removeMemberListDecorator } from "@api/MemberListDecorators";
import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
@ -96,16 +96,16 @@ export default definePlugin({
start() {
if (settings.store.showInMemberList) {
addDecorator("UserVoiceShow", ({ user }) => user == null ? null : <VoiceChannelIndicator userId={user.id} />);
addMemberListDecorator("UserVoiceShow", ({ user }) => user == null ? null : <VoiceChannelIndicator userId={user.id} />);
}
if (settings.store.showInMessages) {
addDecoration("UserVoiceShow", ({ message }) => message?.author == null ? null : <VoiceChannelIndicator userId={message.author.id} isMessageIndicator />);
addMessageDecoration("UserVoiceShow", ({ message }) => message?.author == null ? null : <VoiceChannelIndicator userId={message.author.id} isMessageIndicator />);
}
},
stop() {
removeDecorator("UserVoiceShow");
removeDecoration("UserVoiceShow");
removeMemberListDecorator("UserVoiceShow");
removeMessageDecoration("UserVoiceShow");
},
VoiceChannelIndicator