mirror of
https://github.com/Vendicated/Vencord
synced 2024-09-13 04:29:24 -04:00
Add jumpToStart
This commit is contained in:
parent
4ec01d0f40
commit
7dfa3b402b
1 changed files with 41 additions and 0 deletions
41
src/plugins/jumpToStart/index.tsx
Normal file
41
src/plugins/jumpToStart/index.tsx
Normal 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
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue