Plugin
BiggerStreamPreview
This plugin allows you to enlarge stream previews
1
import { NavContextMenuPatchCallback } from "@api/ContextMenu";2
import { ScreenshareIcon } from "@components/Icons";3
import { Devs } from "@utils/constants";4
import { openImageModal } from "@utils/discord";5
import definePlugin from "@utils/types";6
import { ApplicationStream, Channel, Stream, User } from "@vencord/discord-types";7
import { ApplicationStreamingStore, ApplicationStreamPreviewStore, Menu } from "@webpack/common";8
9
export interface UserContextProps {10
channel: Channel,11
channelSelected: boolean,12
className: string,13
config: { context: string; };14
context: string,15
onHeightUpdate: Function,16
position: string,17
target: HTMLElement,18
theme: string,19
user: User;20
}21
22
export interface StreamContextProps {23
appContext: string,24
className: string,25
config: { context: string; };26
context: string,27
exitFullscreen: Function,28
onHeightUpdate: Function,29
position: string,30
target: HTMLElement,31
stream: Stream,32
theme: string,33
}34
35
export const handleViewPreview = async ({ guildId, channelId, ownerId }: ApplicationStream | Stream) => {36
const previewUrl = await ApplicationStreamPreviewStore.getPreviewURL(guildId, channelId, ownerId);37
if (!previewUrl) return;38
39
openImageModal({40
url: previewUrl,41
height: 720,42
width: 128043
});44
};45
46
export const addViewStreamContext: NavContextMenuPatchCallback = (children, { userId }: { userId: string | bigint; }) => {47
const stream = ApplicationStreamingStore.getAnyStreamForUser(userId);48
if (!stream) return;49
50
const streamPreviewItem = (51
<Menu.MenuItem52
label="View Stream Preview"53
id="view-stream-preview"54
icon={ScreenshareIcon}55
action={() => stream && handleViewPreview(stream)}56
disabled={!stream}57
/>58
);59
60
children.push(<Menu.MenuSeparator />, streamPreviewItem);61
};62
63
export const streamContextPatch: NavContextMenuPatchCallback = (children, { stream }: StreamContextProps) => {64
return addViewStreamContext(children, { userId: stream.ownerId });65
};66
67
export const userContextPatch: NavContextMenuPatchCallback = (children, { user }: UserContextProps) => {68
if (user) return addViewStreamContext(children, { userId: user.id });69
};70
71
export default definePlugin({72
name: "BiggerStreamPreview",73
description: "This plugin allows you to enlarge stream previews",74
tags: ["Media", "Appearance"],75
authors: [Devs.phil],76
contextMenus: {77
"user-context": userContextPatch,78
"stream-context": streamContextPatch79
}80
});81