forked from Vendicated/Vencord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jump to start
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
}); |