Add jumpToStart

This commit is contained in:
Sam 2024-06-11 11:49:52 +01:00
parent 4ec01d0f40
commit 7dfa3b402b

View file

@ -0,0 +1,41 @@
/*
* 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(
<Menu.MenuItem
id="vc-jump-to-first"
label="Jump To First Message"
action={() => {
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
}
});