From 7189b34dad327fc84dde30da15881fbd302155fb Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Mon, 15 Sep 2025 09:53:48 -0400 Subject: [PATCH] AutoJump -> JumpTo & Remove Automatic Jump --- src/equicordplugins/autoJump/index.tsx | 80 ----------------------- src/equicordplugins/jumpTo/index.tsx | 59 +++++++++++++++++ src/equicordplugins/jumpToStart/index.tsx | 41 ------------ 3 files changed, 59 insertions(+), 121 deletions(-) delete mode 100644 src/equicordplugins/autoJump/index.tsx create mode 100644 src/equicordplugins/jumpTo/index.tsx delete mode 100644 src/equicordplugins/jumpToStart/index.tsx diff --git a/src/equicordplugins/autoJump/index.tsx b/src/equicordplugins/autoJump/index.tsx deleted file mode 100644 index 2a6824dd6..000000000 --- a/src/equicordplugins/autoJump/index.tsx +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 { EquicordDevs } from "@utils/constants"; -import definePlugin from "@utils/types"; -import { Menu, ChannelStore, NavigationRouter, FluxDispatcher, MessageActions, MessageStore } from "@webpack/common"; - -interface ChannelSelectEvent { - type: "CHANNEL_SELECT"; - channelId: string | null; - guildId: string | null; -} - -let lastChan = "0"; - -function jumpToPresent(channelId, { limit }: { limit?: number } = {}) { - MessageActions.trackJump(channelId, null, "Present"); - - const jump = { present: true }; - - if (MessageStore.hasPresent(channelId)) { - FluxDispatcher.dispatch({ - type: "LOAD_MESSAGES_SUCCESS_CACHED", - jump, - channelId, - limit - }); - } else { - MessageActions.fetchMessages({ - channelId, - limit, - jump - }); - } -} - -function autoJump(channel: any) { - const guildId = channel.guild_id ?? "@me"; - const channelId = channel.id; - - if (channelId === lastChan) return; - - NavigationRouter.transitionTo(`/channels/${guildId}/${channelId}`); - lastChan = channelId; - - jumpToPresent(channelId, { limit: 100 }); -} - -const MenuPatch: NavContextMenuPatchCallback = (children, { channel }) => { - children.push( - autoJump(channel)} - /> - ); -}; - -export default definePlugin({ - name: "AutoJump", - description: "Automatically jumps to the last message in selected channel & adds a context-menu option to jump to the last message.", - authors: [EquicordDevs.omaw], - contextMenus: { - "channel-context": MenuPatch, - "user-context": MenuPatch, - "thread-context": MenuPatch - }, - flux: { - async CHANNEL_SELECT({ guildId, channelId }: ChannelSelectEvent) { - if (!guildId || !channelId) return; - const channel = ChannelStore.getChannel(channelId); - if (!channel || lastChan === channel.id) return; - autoJump(channel); - } - } -}); diff --git a/src/equicordplugins/jumpTo/index.tsx b/src/equicordplugins/jumpTo/index.tsx new file mode 100644 index 000000000..ea60ba09b --- /dev/null +++ b/src/equicordplugins/jumpTo/index.tsx @@ -0,0 +1,59 @@ +/* + * 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 { migratePluginSettings } from "@api/Settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { Menu, NavigationRouter, RestAPI } from "@webpack/common"; + +function jumpToFirstMessage(props) { + const guildid = props.guild_id !== null ? props.guild_id : "@me"; + const channelid = props.id; + const url = `/channels/${guildid}/${channelid}/0`; + NavigationRouter.transitionTo(url); +} + +async function jumpToBottom(props) { + const guildid = props.guild_id ?? "@me"; + const channelid = props.id; + const res = await RestAPI.get({ + url: `/channels/${channelid}/messages?limit=1` + }); + + const lastMessageId = res.body?.[0]?.id; + if (!lastMessageId) return; + + const url = `/channels/${guildid}/${channelid}/${lastMessageId}`; + NavigationRouter.transitionTo(url); +} + +const MenuPatch: NavContextMenuPatchCallback = (children, { channel }) => { + children.push( + jumpToFirstMessage(channel)} + />, + jumpToBottom(channel)} + /> + ); +}; + +migratePluginSettings("JumpTo", "JumpToStart", "AutoJump"); +export default definePlugin({ + name: "JumpTo", + description: "Adds context menu options to jump to the start or bottom of a channel/DM", + authors: [Devs.Samwich, Devs.thororen], + contextMenus: { + "channel-context": MenuPatch, + "user-context": MenuPatch, + "thread-context": MenuPatch + } +}); diff --git a/src/equicordplugins/jumpToStart/index.tsx b/src/equicordplugins/jumpToStart/index.tsx deleted file mode 100644 index ccf467a01..000000000 --- a/src/equicordplugins/jumpToStart/index.tsx +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; -import { Menu, NavigationRouter } from "@webpack/common"; - -function jumpToFirstMessage(props) { - const guildid = props.guild_id !== null ? props.guild_id : "@me"; - const channelid = props.id; - const url = `/channels/${guildid}/${channelid}/0`; - NavigationRouter.transitionTo(url); -} - -const MenuPatch: NavContextMenuPatchCallback = (children, { channel }) => { - children.push( - { - jumpToFirstMessage(channel); - }} - /> - ); -}; - -export default definePlugin({ - name: "JumpToStart", - description: "Adds a context menu option to jump to the start of a channel/DM", - authors: [Devs.Samwich], - contextMenus: - { - "channel-context": MenuPatch, - "user-context": MenuPatch, - "thread-context": MenuPatch - } -});