Plugin

BiggerStreamPreview

This plugin allows you to enlarge stream previews

Media Appearance
index.tsx
Download

Source

src/plugins/biggerStreamPreview/index.tsx
1import { NavContextMenuPatchCallback } from "@api/ContextMenu";
2import { ScreenshareIcon } from "@components/Icons";
3import { Devs } from "@utils/constants";
4import { openImageModal } from "@utils/discord";
5import definePlugin from "@utils/types";
6import { ApplicationStream, Channel, Stream, User } from "@vencord/discord-types";
7import { ApplicationStreamingStore, ApplicationStreamPreviewStore, Menu } from "@webpack/common";
8
9export 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
22export 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
35export 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: 1280
43 });
44};
45
46export const addViewStreamContext: NavContextMenuPatchCallback = (children, { userId }: { userId: string | bigint; }) => {
47 const stream = ApplicationStreamingStore.getAnyStreamForUser(userId);
48 if (!stream) return;
49
50 const streamPreviewItem = (
51 <Menu.MenuItem
52 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
63export const streamContextPatch: NavContextMenuPatchCallback = (children, { stream }: StreamContextProps) => {
64 return addViewStreamContext(children, { userId: stream.ownerId });
65};
66
67export const userContextPatch: NavContextMenuPatchCallback = (children, { user }: UserContextProps) => {
68 if (user) return addViewStreamContext(children, { userId: user.id });
69};
70
71export 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": streamContextPatch
79 }
80});
81