Skip to content

Commit

Permalink
Picture Links: temporarily disable server pfp patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico040 authored Jun 18, 2024
1 parent d780b3c commit 54576d8
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions plugins/picture-links/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,41 +80,41 @@ const unpatchBanner = after("default", ProfileBanner, ([{ bannerSource }], res)
return <Pressable onPress={({ nativeEvent }) => openModal(url, nativeEvent)}>{res}</Pressable>;
});

var unpatchGuildIcon
//var unpatchGuildIcon

if (typeof findByName("GuildIcon").prototype.render !== "undefined") {
// Compatibility patch with older versions
const GuildIcon = findByName("GuildIcon");
unpatchGuildIcon = after("render", GuildIcon.prototype, function (_, res) {
if (this.props?.size !== "XLARGE") return;
const url = this.props?.guild?.getIconURL?.(4096);
if (!url) return res;

return (
<Pressable onPress={({ nativeEvent }) => openModal(url, nativeEvent)}>
{res}
</Pressable>
);
});
} else {
// Patch for newer versions
const GuildIcon = findByName("GuildIcon", false);
unpatchGuildIcon = after("default", GuildIcon, ([{ size, guild }], res) => {
if (size !== "XLARGE" || guild?.icon == null) return;
var ext = "png"
if (guild?.icon.includes('a_')) { ext = "gif"; }
const url = `https://cdn.discordapp.com/icons/${guild?.id}/${guild?.icon}.${ext}?size=4096`

return (
<Pressable onPress={({ nativeEvent }) => openModal(url, nativeEvent)}>
{res}
</Pressable>
);
});
}
//if (typeof findByName("GuildIcon").prototype.render !== "undefined") {
// // Compatibility patch with older versions
// const GuildIcon = findByName("GuildIcon");
// unpatchGuildIcon = after("render", GuildIcon.prototype, function (_, res) {
// if (this.props?.size !== "XLARGE") return;
// const url = this.props?.guild?.getIconURL?.(4096);
// if (!url) return res;
//
// return (
// <Pressable onPress={({ nativeEvent }) => openModal(url, nativeEvent)}>
// {res}
// </Pressable>
// );
// });
//} else {
// // Patch for newer versions
// const GuildIcon = findByName("GuildIcon", false);
// unpatchGuildIcon = after("default", GuildIcon, ([{ size, guild }], res) => {
// if (size !== "XLARGE" || guild?.icon == null) return;
// var ext = "png"
// if (guild?.icon.includes('a_')) { ext = "gif"; }
// const url = `https://cdn.discordapp.com/icons/${guild?.id}/${guild?.icon}.${ext}?size=4096`
//
// return (
// <Pressable onPress={({ nativeEvent }) => openModal(url, nativeEvent)}>
// {res}
// </Pressable>
// );
// });
//}

export function onUnload() {
unpatchAvatar();
unpatchBanner();
unpatchGuildIcon();
// unpatchGuildIcon();
}

0 comments on commit 54576d8

Please sign in to comment.