Skip to content

Commit

Permalink
[Plugin] Jump to start
Browse files Browse the repository at this point in the history
Jump to start
  • Loading branch information
Scyye committed Jun 12, 2024
2 parents e3400f9 + 98d0a97 commit 46fc837
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/plugins/jumpToStart/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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,
"thread-context": MenuPatch
}
});

0 comments on commit 46fc837

Please sign in to comment.