Skip to content

Commit

Permalink
mediaTweaks: fix enlarge video and inline playback
Browse files Browse the repository at this point in the history
  • Loading branch information
Cynosphere committed Oct 26, 2024
1 parent 1194788 commit b065ae7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/mediaTweaks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export const patches: Patch[] = [
{
find: 'location:"MessageAccessories"',
replace: {
match: /=.\.length>1\?(\(0,.\..{1,2}\))\((.),(.)\):{}/,
replacement: (_, createCarousel, attachments, analytics) =>
`=${attachments}.length>1?${createCarousel}((moonlight.getConfigOption("mediaTweaks","inlineMosaicPlayback")??true)?${attachments}.filter(x=>!x.component.props.poster):${attachments},${analytics}):{}`
match: /=.\.length>1\?(\(0,.\..{1,2}\))\((.),({shouldRedactExplicitContent:.,shouldHideMediaOptions:.}),(.)\):{}/,
replacement: (_, createCarousel, attachments, props, analytics) =>
`=${attachments}.length>1?${createCarousel}((moonlight.getConfigOption("mediaTweaks","inlineMosaicPlayback")??true)?${attachments}.filter(x=>x.type!="VIDEO"):${attachments},${props},${analytics}):{}`
}
},

Expand Down
2 changes: 1 addition & 1 deletion src/mediaTweaks/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://moonlight-mod.github.io/manifest.schema.json",
"id": "mediaTweaks",
"version": "1.0.3",
"version": "1.0.4",
"meta": {
"name": "Media Tweaks",
"tagline": "Various tweaks to images and videos. Every feature togglable.",
Expand Down
35 changes: 15 additions & 20 deletions src/mediaTweaks/webpackModules/enlargeVideoButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "@moonlight-mod/wp/react";
import spacepack from "@moonlight-mod/wp/spacepack_spacepack";
import * as Components from "@moonlight-mod/wp/discord/components/common/index";

const { Clickable, Tooltip, MaximizeIcon, openModal, ModalRoot, ModalSize } = Components;
const { Clickable, Tooltip, MaximizeIcon, openModal } = Components;

const HoverButtonClasses = spacepack.findByExports("hoverButton")[0].exports;

Expand All @@ -26,7 +26,7 @@ type MimeType = {
compressible?: boolean;
};

const MediaModal = spacepack.findByCode(".Messages.MEDIA_VIEWER_MODAL_ALT_TEXT,")[0]?.exports?.default;
const LazyMediaModal = spacepack.findFunctionByStrings(spacepack.findByCode(/let{location:.,contextKey:/, "openModalLazy")[0]?.exports ?? {}, "openModalLazy");
const MediaModalClasses = spacepack.findByCode(/\.exports={modal:"modal_[a-z0-9]+"}/)[0].exports;

const MimeTypes = Object.entries(
Expand All @@ -43,24 +43,19 @@ export default function EnlargeVideoButton({ mimeType, item }: HoverButtonsProps
focusProps={{ offset: 2 }}
aria-label="Enlarge Video"
onClick={() => {
if (MediaModal != null) {
openModal((modalProps: any) => {
return (
<MediaModal
{...modalProps}
className={MediaModalClasses.modal}
items={[
{
url: item.originalItem.proxy_url,
proxyUrl: item.originalItem.proxy_url,
width: item.originalItem.width,
height: item.originalItem.height,
type: "VIDEO",
origina: item.originalItem.proxy_url
}
]}
/>
);
if (LazyMediaModal != null) {
LazyMediaModal({
className: MediaModalClasses.modal,
items: [
{
url: item.originalItem.proxy_url,
proxyUrl: item.originalItem.proxy_url,
width: item.originalItem.width,
height: item.originalItem.height,
type: "VIDEO",
origina: item.originalItem.proxy_url
}
]
});
}
}}
Expand Down

0 comments on commit b065ae7

Please sign in to comment.