mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 01:46:23 +00:00
rename API methods to have more informative names
This commit is contained in:
parent
cff2c53972
commit
f6803d0c55
12 changed files with 48 additions and 48 deletions
|
@ -57,7 +57,7 @@ const Badges = new Set<ProfileBadge>();
|
||||||
* Register a new badge with the Badges API
|
* Register a new badge with the Badges API
|
||||||
* @param badge The badge to register
|
* @param badge The badge to register
|
||||||
*/
|
*/
|
||||||
export function addBadge(badge: ProfileBadge) {
|
export function addProfileBadge(badge: ProfileBadge) {
|
||||||
badge.component &&= ErrorBoundary.wrap(badge.component, { noop: true });
|
badge.component &&= ErrorBoundary.wrap(badge.component, { noop: true });
|
||||||
Badges.add(badge);
|
Badges.add(badge);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ export function addBadge(badge: ProfileBadge) {
|
||||||
* Unregister a badge from the Badges API
|
* Unregister a badge from the Badges API
|
||||||
* @param badge The badge to remove
|
* @param badge The badge to remove
|
||||||
*/
|
*/
|
||||||
export function removeBadge(badge: ProfileBadge) {
|
export function removeProfileBadge(badge: ProfileBadge) {
|
||||||
return Badges.delete(badge);
|
return Badges.delete(badge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,11 @@ type OnlyIn = "guilds" | "dms";
|
||||||
|
|
||||||
export const decorators = new Map<string, { decorator: MemberListDecoratorFactory, onlyIn?: OnlyIn; }>();
|
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 });
|
decorators.set(identifier, { decorator, onlyIn });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeDecorator(identifier: string) {
|
export function removeMemberListDecorator(identifier: string) {
|
||||||
decorators.delete(identifier);
|
decorators.delete(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ export type MessageAccessory = {
|
||||||
|
|
||||||
export const accessories = new Map<String, MessageAccessory>();
|
export const accessories = new Map<String, MessageAccessory>();
|
||||||
|
|
||||||
export function addAccessory(
|
export function addMessageAccessory(
|
||||||
identifier: string,
|
identifier: string,
|
||||||
callback: MessageAccessoryFactory,
|
callback: MessageAccessoryFactory,
|
||||||
position?: number
|
position?: number
|
||||||
|
@ -35,7 +35,7 @@ export function addAccessory(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeAccessory(identifier: string) {
|
export function removeMessageAccessory(identifier: string) {
|
||||||
accessories.delete(identifier);
|
accessories.delete(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,11 +48,11 @@ export type MessageDecorationFactory = (props: MessageDecorationProps) => JSX.El
|
||||||
|
|
||||||
export const decorations = new Map<string, MessageDecorationFactory>();
|
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);
|
decorations.set(identifier, decoration);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeDecoration(identifier: string) {
|
export function removeMessageDecoration(identifier: string) {
|
||||||
decorations.delete(identifier);
|
decorations.delete(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
listeners.add(listener);
|
||||||
return listener;
|
return listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeClickListener(listener: MessageClickListener) {
|
export function removeMessageClickListener(listener: MessageClickListener) {
|
||||||
return listeners.delete(listener);
|
return listeners.delete(listener);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* 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 { definePluginSettings } from "@api/Settings";
|
||||||
import { getUserSettingLazy } from "@api/UserSettings";
|
import { getUserSettingLazy } from "@api/UserSettings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
@ -251,7 +251,7 @@ export default definePlugin({
|
||||||
}, { noop: true }),
|
}, { noop: true }),
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
addAccessory("vencord-debug", props => {
|
addMessageAccessory("vencord-debug", props => {
|
||||||
const buttons = [] as JSX.Element[];
|
const buttons = [] as JSX.Element[];
|
||||||
|
|
||||||
const shouldAddUpdateButton =
|
const shouldAddUpdateButton =
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
import { addChatBarButton, removeChatBarButton } from "@api/ChatButtons";
|
import { addChatBarButton, removeChatBarButton } from "@api/ChatButtons";
|
||||||
import { registerCommand, unregisterCommand } from "@api/Commands";
|
import { registerCommand, unregisterCommand } from "@api/Commands";
|
||||||
import { addContextMenuPatch, removeContextMenuPatch } from "@api/ContextMenu";
|
import { addContextMenuPatch, removeContextMenuPatch } from "@api/ContextMenu";
|
||||||
import { addDecorator, removeDecorator } from "@api/MemberListDecorators";
|
import { addMemberListDecorator, removeMemberListDecorator } from "@api/MemberListDecorators";
|
||||||
import { addAccessory, removeAccessory } from "@api/MessageAccessories";
|
import { addMessageAccessory, removeMessageAccessory } from "@api/MessageAccessories";
|
||||||
import { addDecoration, removeDecoration } from "@api/MessageDecorations";
|
import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";
|
||||||
import { addClickListener, addPreEditListener, addPreSendListener, removeClickListener, removePreEditListener, removePreSendListener } from "@api/MessageEvents";
|
import { addMessageClickListener, addPreEditListener, addPreSendListener, removeMessageClickListener, removePreEditListener, removePreSendListener } from "@api/MessageEvents";
|
||||||
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
|
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
|
||||||
import { Settings } from "@api/Settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
|
@ -279,12 +279,12 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p:
|
||||||
|
|
||||||
if (onBeforeMessageEdit) addPreEditListener(onBeforeMessageEdit);
|
if (onBeforeMessageEdit) addPreEditListener(onBeforeMessageEdit);
|
||||||
if (onBeforeMessageSend) addPreSendListener(onBeforeMessageSend);
|
if (onBeforeMessageSend) addPreSendListener(onBeforeMessageSend);
|
||||||
if (onMessageClick) addClickListener(onMessageClick);
|
if (onMessageClick) addMessageClickListener(onMessageClick);
|
||||||
|
|
||||||
if (renderChatBarButton) addChatBarButton(name, renderChatBarButton);
|
if (renderChatBarButton) addChatBarButton(name, renderChatBarButton);
|
||||||
if (renderMemberListDecorator) addDecorator(name, renderMemberListDecorator);
|
if (renderMemberListDecorator) addMemberListDecorator(name, renderMemberListDecorator);
|
||||||
if (renderMessageDecoration) addDecoration(name, renderMessageDecoration);
|
if (renderMessageDecoration) addMessageDecoration(name, renderMessageDecoration);
|
||||||
if (renderMessageAccessory) addAccessory(name, renderMessageAccessory);
|
if (renderMessageAccessory) addMessageAccessory(name, renderMessageAccessory);
|
||||||
if (renderMessagePopoverButton) addMessagePopoverButton(name, renderMessagePopoverButton);
|
if (renderMessagePopoverButton) addMessagePopoverButton(name, renderMessagePopoverButton);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -336,12 +336,12 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu
|
||||||
|
|
||||||
if (onBeforeMessageEdit) removePreEditListener(onBeforeMessageEdit);
|
if (onBeforeMessageEdit) removePreEditListener(onBeforeMessageEdit);
|
||||||
if (onBeforeMessageSend) removePreSendListener(onBeforeMessageSend);
|
if (onBeforeMessageSend) removePreSendListener(onBeforeMessageSend);
|
||||||
if (onMessageClick) removeClickListener(onMessageClick);
|
if (onMessageClick) removeMessageClickListener(onMessageClick);
|
||||||
|
|
||||||
if (renderChatBarButton) removeChatBarButton(name);
|
if (renderChatBarButton) removeChatBarButton(name);
|
||||||
if (renderMemberListDecorator) removeDecorator(name);
|
if (renderMemberListDecorator) removeMemberListDecorator(name);
|
||||||
if (renderMessageDecoration) removeDecoration(name);
|
if (renderMessageDecoration) removeMessageDecoration(name);
|
||||||
if (renderMessageAccessory) removeAccessory(name);
|
if (renderMessageAccessory) removeMessageAccessory(name);
|
||||||
if (renderMessagePopoverButton) removeMessagePopoverButton(name);
|
if (renderMessagePopoverButton) removeMessagePopoverButton(name);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* 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 { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
@ -65,7 +65,7 @@ export default definePlugin({
|
||||||
document.addEventListener("keydown", keydown);
|
document.addEventListener("keydown", keydown);
|
||||||
document.addEventListener("keyup", keyup);
|
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;
|
const isMe = msg.author.id === UserStore.getCurrentUser().id;
|
||||||
if (!isDeletePressed) {
|
if (!isDeletePressed) {
|
||||||
if (event.detail < 2) return;
|
if (event.detail < 2) return;
|
||||||
|
@ -115,7 +115,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
removeClickListener(this.onClick);
|
removeMessageClickListener(this.onClick);
|
||||||
document.removeEventListener("keydown", keydown);
|
document.removeEventListener("keydown", keydown);
|
||||||
document.removeEventListener("keyup", keyup);
|
document.removeEventListener("keyup", keyup);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* 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 { updateMessage } from "@api/MessageUpdater";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { getUserSettingLazy } from "@api/UserSettings";
|
import { getUserSettingLazy } from "@api/UserSettings";
|
||||||
|
@ -372,7 +372,7 @@ export default definePlugin({
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
addAccessory("messageLinkEmbed", props => {
|
addMessageAccessory("messageLinkEmbed", props => {
|
||||||
if (!messageLinkRegex.test(props.message.content))
|
if (!messageLinkRegex.test(props.message.content))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -390,6 +390,6 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
removeAccessory("messageLinkEmbed");
|
removeMessageAccessory("messageLinkEmbed");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
|
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
|
|
||||||
import { addBadge, BadgePosition, BadgeUserArgs, ProfileBadge, removeBadge } from "@api/Badges";
|
import { addProfileBadge, BadgePosition, BadgeUserArgs, ProfileBadge, removeProfileBadge } from "@api/Badges";
|
||||||
import { addDecorator, removeDecorator } from "@api/MemberListDecorators";
|
import { addMemberListDecorator, removeMemberListDecorator } from "@api/MemberListDecorators";
|
||||||
import { addDecoration, removeDecoration } from "@api/MessageDecorations";
|
import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";
|
||||||
import { Settings } from "@api/Settings";
|
import { Settings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
@ -172,26 +172,26 @@ const badge: ProfileBadge = {
|
||||||
const indicatorLocations = {
|
const indicatorLocations = {
|
||||||
list: {
|
list: {
|
||||||
description: "In the member list",
|
description: "In the member list",
|
||||||
onEnable: () => addDecorator("platform-indicator", props =>
|
onEnable: () => addMemberListDecorator("platform-indicator", props =>
|
||||||
<ErrorBoundary noop>
|
<ErrorBoundary noop>
|
||||||
<PlatformIndicator user={props.user} small={true} />
|
<PlatformIndicator user={props.user} small={true} />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
),
|
),
|
||||||
onDisable: () => removeDecorator("platform-indicator")
|
onDisable: () => removeMemberListDecorator("platform-indicator")
|
||||||
},
|
},
|
||||||
badges: {
|
badges: {
|
||||||
description: "In user profiles, as badges",
|
description: "In user profiles, as badges",
|
||||||
onEnable: () => addBadge(badge),
|
onEnable: () => addProfileBadge(badge),
|
||||||
onDisable: () => removeBadge(badge)
|
onDisable: () => removeProfileBadge(badge)
|
||||||
},
|
},
|
||||||
messages: {
|
messages: {
|
||||||
description: "Inside messages",
|
description: "Inside messages",
|
||||||
onEnable: () => addDecoration("platform-indicator", props =>
|
onEnable: () => addMessageDecoration("platform-indicator", props =>
|
||||||
<ErrorBoundary noop>
|
<ErrorBoundary noop>
|
||||||
<PlatformIndicator user={props.message?.author} wantTopMargin={true} />
|
<PlatformIndicator user={props.message?.author} wantTopMargin={true} />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
),
|
),
|
||||||
onDisable: () => removeDecoration("platform-indicator")
|
onDisable: () => removeMessageDecoration("platform-indicator")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import "./styles.css";
|
||||||
|
|
||||||
import { addChatBarButton, removeChatBarButton } from "@api/ChatButtons";
|
import { addChatBarButton, removeChatBarButton } from "@api/ChatButtons";
|
||||||
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
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 { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
|
||||||
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
|
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
@ -64,7 +64,7 @@ export default definePlugin({
|
||||||
translate,
|
translate,
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
addAccessory("vc-translation", props => <TranslationAccessory message={props.message} />);
|
addMessageAccessory("vc-translation", props => <TranslationAccessory message={props.message} />);
|
||||||
|
|
||||||
addChatBarButton("vc-translate", TranslateChatBarIcon);
|
addChatBarButton("vc-translate", TranslateChatBarIcon);
|
||||||
|
|
||||||
|
@ -102,6 +102,6 @@ export default definePlugin({
|
||||||
removePreSendListener(this.preSend);
|
removePreSendListener(this.preSend);
|
||||||
removeChatBarButton("vc-translate");
|
removeChatBarButton("vc-translate");
|
||||||
removeMessagePopoverButton("vc-translate");
|
removeMessagePopoverButton("vc-translate");
|
||||||
removeAccessory("vc-translation");
|
removeMessageAccessory("vc-translation");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
|
|
||||||
import { addDecorator, removeDecorator } from "@api/MemberListDecorators";
|
import { addMemberListDecorator, removeMemberListDecorator } from "@api/MemberListDecorators";
|
||||||
import { addDecoration, removeDecoration } from "@api/MessageDecorations";
|
import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
@ -96,16 +96,16 @@ export default definePlugin({
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
if (settings.store.showInMemberList) {
|
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) {
|
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() {
|
stop() {
|
||||||
removeDecorator("UserVoiceShow");
|
removeMemberListDecorator("UserVoiceShow");
|
||||||
removeDecoration("UserVoiceShow");
|
removeMessageDecoration("UserVoiceShow");
|
||||||
},
|
},
|
||||||
|
|
||||||
VoiceChannelIndicator
|
VoiceChannelIndicator
|
||||||
|
|
Loading…
Reference in a new issue