diff --git a/src/components/PluginSettings/styles.css b/src/components/PluginSettings/styles.css index ce131729..488fd212 100644 --- a/src/components/PluginSettings/styles.css +++ b/src/components/PluginSettings/styles.css @@ -252,7 +252,7 @@ } .visual-refresh .button-danger-background:hover { - background-color: var(--status-danger-background) !important; + background-color: var(--status-danger-background) !important; color: var(--status-danger-text) !important; } @@ -261,15 +261,15 @@ border: 1px solid var(--border-subtle) !important; &:hover { - background-color: var(--card-primary-bg) !important; + background-color: var(--card-primary-bg) !important; } - } +} .visual-refresh .vc-plugin-stats { background-color: var(--card-primary-bg) !important; border: 1px solid var(--border-subtle) !important; &:hover { - background-color: var(--card-primary-bg) !important; + background-color: var(--card-primary-bg) !important; } } diff --git a/src/equicordplugins/autoJump/index.tsx b/src/equicordplugins/autoJump/index.tsx new file mode 100644 index 00000000..b05ba1e6 --- /dev/null +++ b/src/equicordplugins/autoJump/index.tsx @@ -0,0 +1,69 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { NavContextMenuPatchCallback } from "@api/ContextMenu"; +import { definePluginSettings } from "@api/Settings"; +import { EquicordDevs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { ChannelStore, Menu, MessageActions, NavigationRouter } from "@webpack/common"; + +interface ChannelSelectEvent { + type: "CHANNEL_SELECT"; + channelId: string | null; + guildId: string | null; +} + +let lastChannelId = "0"; + +function autoJump({ guild_id, id: channelId }) { + const guildId = guild_id ?? "@me"; + + lastChannelId = channelId; + NavigationRouter.transitionTo(`/channels/${guildId}/${channelId}`); + MessageActions.jumpToPresent(channelId, { limit: null }); +} + +const MenuPatch: NavContextMenuPatchCallback = (children, { channel }) => { + children.push( + { + autoJump(channel); + }} + /> + ); +}; + +const settings = definePluginSettings({ + autoJumping: { + type: OptionType.BOOLEAN, + description: "Automatically jump to the last message in the channel when switching channels", + default: false + } +}); + +export default definePlugin({ + name: "AutoJump", + description: "Jumps to Last Message in Channel", + authors: [EquicordDevs.omaw], + settings, + contextMenus: { + "channel-context": MenuPatch, + "user-context": MenuPatch, + "thread-context": MenuPatch + }, + flux: { + async CHANNEL_SELECT({ guildId, channelId }: ChannelSelectEvent) { + if (!settings.store.autoJumping || !channelId) return; + + const channel = ChannelStore.getChannel(channelId); + if (!channel || channel.id === lastChannelId) return; + + autoJump({ guild_id: guildId, id: channelId }); + } + } +}); diff --git a/src/equicordplugins/purgeMessages/index.tsx b/src/equicordplugins/purgeMessages/index.tsx index 425754fb..03269bf8 100644 --- a/src/equicordplugins/purgeMessages/index.tsx +++ b/src/equicordplugins/purgeMessages/index.tsx @@ -21,12 +21,9 @@ import "@equicordplugins/_misc/styles.css"; import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands"; import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; -import { findByPropsLazy } from "@webpack"; -import { Forms, MessageStore, UserStore } from "@webpack/common"; +import { Forms, MessageActions, MessageStore, UserStore } from "@webpack/common"; import { Channel, Message } from "discord-types/general"; -const MessageActions = findByPropsLazy("deleteMessage", "startEditMessage"); - async function deleteMessages(amount: number, channel: Channel, delay: number = 1500): Promise { let deleted = 0; const userId = UserStore.getCurrentUser().id;