mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-19 22:20:34 +00:00
Merge pull request #1 from byeoon/fixEmoteCloneQuality
This commit is contained in:
commit
6022317d5e
16 changed files with 54 additions and 35 deletions
|
@ -315,7 +315,6 @@ export default function PluginSettings() {
|
|||
<TextInput autoFocus value={searchValue.value} placeholder="Search for a plugin..." onChange={onSearch} className={Margins.bottom20} />
|
||||
<div className={InputStyles.inputWrapper}>
|
||||
<Select
|
||||
className={InputStyles.inputDefault}
|
||||
options={[
|
||||
{ label: "Show All", value: SearchStatus.ALL, default: true },
|
||||
{ label: "Show Enabled", value: SearchStatus.ENABLED },
|
||||
|
|
|
@ -28,7 +28,7 @@ const VENCORD_SRC_DIR = join(__dirname, "..");
|
|||
|
||||
const execFile = promisify(cpExecFile);
|
||||
|
||||
const isFlatpak = process.platform === "linux" && Boolean(process.env.FLATPAK_ID?.includes("discordapp") || process.env.FLATPAK_ID?.includes("Discord"));
|
||||
const isFlatpak = process.platform === "linux" && !!process.env.FLATPAK_ID;
|
||||
|
||||
if (process.platform === "darwin") process.env.PATH = `/usr/local/bin:${process.env.PATH}`;
|
||||
|
||||
|
@ -60,7 +60,8 @@ async function calculateGitChanges() {
|
|||
return commits ? commits.split("\n").map(line => {
|
||||
const [author, hash, ...rest] = line.split("/");
|
||||
return {
|
||||
hash, author, message: rest.join("/")
|
||||
hash, author,
|
||||
message: rest.join("/").split("\n")[0]
|
||||
};
|
||||
}) : [];
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ async function calculateGitChanges() {
|
|||
// github api only sends the long sha
|
||||
hash: c.sha.slice(0, 7),
|
||||
author: c.author.login,
|
||||
message: c.commit.message.substring(c.commit.message.indexOf("\n") + 1)
|
||||
message: c.commit.message.split("\n")[0]
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -54,9 +54,9 @@ const StickerExt = [, "png", "png", "json", "gif"] as const;
|
|||
|
||||
function getUrl(data: Data) {
|
||||
if (data.t === "Emoji")
|
||||
return `${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/emojis/${data.id}.${data.isAnimated ? "gif" : "png"}`;
|
||||
return `${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/emojis/${data.id}.${data.isAnimated ? "gif" : "png"}?size=4096&lossless=true`;
|
||||
|
||||
return `${window.GLOBAL_ENV.MEDIA_PROXY_ENDPOINT}/stickers/${data.id}.${StickerExt[data.format_type]}`;
|
||||
return `${window.GLOBAL_ENV.MEDIA_PROXY_ENDPOINT}/stickers/${data.id}.${StickerExt[data.format_type]}?size=4096&lossless=true`;
|
||||
}
|
||||
|
||||
async function fetchSticker(id: string) {
|
||||
|
@ -130,7 +130,8 @@ function getGuildCandidates(data: Data) {
|
|||
|
||||
let count = 0;
|
||||
for (const emoji of emojis)
|
||||
if (emoji.animated === isAnimated) count++;
|
||||
if (emoji.animated === isAnimated && !emoji.managed)
|
||||
count++;
|
||||
return count < emojiSlots;
|
||||
}).sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import { Logger } from "@utils/Logger";
|
|||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack";
|
||||
import { Alerts, ChannelStore, EmojiStore, FluxDispatcher, Forms, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common";
|
||||
import type { CustomEmoji } from "@webpack/types";
|
||||
import type { Message } from "discord-types/general";
|
||||
import { applyPalette, GIFEncoder, quantize } from "gifenc";
|
||||
import type { ReactElement, ReactNode } from "react";
|
||||
|
@ -784,6 +785,16 @@ export default definePlugin({
|
|||
UploadHandler.promptToUpload([file], ChannelStore.getChannel(channelId), DRAFT_TYPE);
|
||||
},
|
||||
|
||||
canUseEmote(e: CustomEmoji, channelId: string) {
|
||||
if (e.require_colons === false) return true;
|
||||
if (e.available === false) return false;
|
||||
|
||||
if (this.canUseEmotes)
|
||||
return e.guildId === this.guildId || hasExternalEmojiPerms(channelId);
|
||||
else
|
||||
return !e.animated && e.guildId === this.guildId;
|
||||
},
|
||||
|
||||
start() {
|
||||
const s = settings.store;
|
||||
|
||||
|
@ -882,12 +893,8 @@ export default definePlugin({
|
|||
}
|
||||
|
||||
if (s.enableEmojiBypass) {
|
||||
const canUseEmotes = this.canUseEmotes && hasExternalEmojiPerms(channelId);
|
||||
|
||||
for (const emoji of messageObj.validNonShortcutEmojis) {
|
||||
if (!emoji.require_colons) continue;
|
||||
if (emoji.available !== false && canUseEmotes) continue;
|
||||
if (emoji.guildId === guildId && !emoji.animated) continue;
|
||||
if (this.canUseEmote(emoji, channelId)) continue;
|
||||
|
||||
hasBypass = true;
|
||||
|
||||
|
@ -917,18 +924,12 @@ export default definePlugin({
|
|||
this.preEdit = addPreEditListener(async (channelId, __, messageObj) => {
|
||||
if (!s.enableEmojiBypass) return;
|
||||
|
||||
const { guildId } = this;
|
||||
|
||||
let hasBypass = false;
|
||||
|
||||
const canUseEmotes = this.canUseEmotes && hasExternalEmojiPerms(channelId);
|
||||
|
||||
messageObj.content = messageObj.content.replace(/(?<!\\)<a?:(?:\w+):(\d+)>/ig, (emojiStr, emojiId, offset, origStr) => {
|
||||
const emoji = EmojiStore.getCustomEmojiById(emojiId);
|
||||
if (emoji == null) return emojiStr;
|
||||
if (!emoji.require_colons) return emojiStr;
|
||||
if (emoji.available !== false && canUseEmotes) return emojiStr;
|
||||
if (emoji.guildId === guildId && !emoji.animated) return emojiStr;
|
||||
if (this.canUseEmote(emoji, channelId)) return emojiStr;
|
||||
|
||||
hasBypass = true;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { addAccessory } from "@api/MessageAccessories";
|
||||
import { addAccessory, removeAccessory } from "@api/MessageAccessories";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants.js";
|
||||
|
@ -389,4 +389,8 @@ export default definePlugin({
|
|||
);
|
||||
}, 4 /* just above rich embeds */);
|
||||
},
|
||||
|
||||
stop() {
|
||||
removeAccessory("messageLinkEmbed");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -45,7 +45,7 @@ export default definePlugin({
|
|||
|
||||
patches: [
|
||||
{
|
||||
find: ".Messages.USER_PROFILE_MODAL", // Note: the module is lazy-loaded
|
||||
find: ".Messages.MUTUAL_GUILDS_WITH_END_COUNT", // Note: the module is lazy-loaded
|
||||
replacement: {
|
||||
match: /(?<=\.tabBarItem.{0,50}MUTUAL_GUILDS.+?}\),)(?=.+?(\(0,\i\.jsxs?\)\(.{0,100}id:))/,
|
||||
replace: '(arguments[0].user.bot||arguments[0].isCurrentUser)?null:$1"MUTUAL_GDMS",children:"Mutual Groups"}),'
|
||||
|
|
|
@ -9,7 +9,7 @@ import { Settings } from "@api/Settings";
|
|||
import { UserStore } from "@webpack/common";
|
||||
|
||||
import { DEFAULT_COLOR } from "./constants";
|
||||
import { forceUpdate } from "./index";
|
||||
import { forceUpdate, PinOrder, PrivateChannelSortStore, settings } from "./index";
|
||||
|
||||
export interface Category {
|
||||
id: string;
|
||||
|
@ -106,7 +106,12 @@ export function categoryLen() {
|
|||
}
|
||||
|
||||
export function getAllUncollapsedChannels() {
|
||||
return categories.filter(c => !c.collapsed).map(c => c.channels).flat();
|
||||
if (settings.store.pinOrder === PinOrder.LastMessage) {
|
||||
const sortedChannels = PrivateChannelSortStore.getPrivateChannelIds();
|
||||
return categories.filter(c => !c.collapsed).flatMap(c => sortedChannels.filter(channel => c.channels.includes(channel)));
|
||||
}
|
||||
|
||||
return categories.filter(c => !c.collapsed).flatMap(c => c.channels);
|
||||
}
|
||||
|
||||
export function getSections() {
|
||||
|
|
|
@ -29,7 +29,7 @@ interface ChannelComponentProps {
|
|||
|
||||
const headerClasses = findByPropsLazy("privateChannelsHeaderContainer");
|
||||
|
||||
const PrivateChannelSortStore = findStoreLazy("PrivateChannelSortStore") as { getPrivateChannelIds: () => string[]; };
|
||||
export const PrivateChannelSortStore = findStoreLazy("PrivateChannelSortStore") as { getPrivateChannelIds: () => string[]; };
|
||||
|
||||
export let instance: any;
|
||||
export const forceUpdate = () => instance?.props?._forceUpdate?.();
|
||||
|
@ -236,7 +236,7 @@ export default definePlugin({
|
|||
const category = categories[categoryIndex - 1];
|
||||
if (!category) return false;
|
||||
|
||||
return category.collapsed && this.instance.props.selectedChannelId !== category.channels[channelIndex];
|
||||
return category.collapsed && this.instance.props.selectedChannelId !== this.getCategoryChannels(category)[channelIndex];
|
||||
},
|
||||
|
||||
getScrollOffset(channelId: string, rowHeight: number, padding: number, preRenderedChildren: number, originalOffset: number) {
|
||||
|
|
|
@ -89,8 +89,8 @@ export default definePlugin({
|
|||
{
|
||||
find: "61eef9_2",
|
||||
replacement: {
|
||||
match: /(?<=getMutableGuildChannelsForGuild\(\i\)\);)(?=if\(null==\i\|\|)/,
|
||||
replace: "if($self.useForceServerHome())return false;"
|
||||
match: /getMutableGuildChannelsForGuild\(\i\);return\(0,\i\.useStateFromStores\).+?\]\)(?=}function)/,
|
||||
replace: m => `${m}&&!$self.useForceServerHome()`
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
@ -71,7 +71,7 @@ export const settings = definePluginSettings({
|
|||
</Button>
|
||||
|
||||
<Button onClick={async () => {
|
||||
let url = "https://reviewdb.mantikafasi.dev/";
|
||||
let url = "https://reviewdb.mantikafasi.dev";
|
||||
const token = await getToken();
|
||||
if (token)
|
||||
url += "/api/redirect?token=" + encodeURIComponent(token);
|
||||
|
|
|
@ -452,7 +452,7 @@ export default definePlugin({
|
|||
{
|
||||
// Filter hidden channels from GuildChannelStore.getChannels unless told otherwise
|
||||
match: /(?<=getChannels\(\i)(\){.+?)return (.+?)}/,
|
||||
replace: (_, rest, channels) => `,shouldIncludeHidden${rest}return $self.resolveGuildChannels(${channels},shouldIncludeHidden??false);}`
|
||||
replace: (_, rest, channels) => `,shouldIncludeHidden${rest}return $self.resolveGuildChannels(${channels},shouldIncludeHidden??arguments[0]==="@favorites");}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
*/
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import { LazyComponent } from "@utils/react";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
import StartupTimingPage from "./StartupTimingPage";
|
||||
|
||||
export default definePlugin({
|
||||
name: "StartupTimings",
|
||||
description: "Adds Startup Timings to the Settings menu",
|
||||
|
@ -31,5 +32,5 @@ export default definePlugin({
|
|||
replace: '{section:"StartupTimings",label:"Startup Timings",element:$self.StartupTimingPage},$&'
|
||||
}
|
||||
}],
|
||||
StartupTimingPage: LazyComponent(() => require("./StartupTimingPage").default)
|
||||
StartupTimingPage
|
||||
});
|
||||
|
|
|
@ -104,7 +104,7 @@ export default definePlugin({
|
|||
},
|
||||
// below username
|
||||
{
|
||||
find: ".USER_PROFILE_MODAL",
|
||||
find: ".Messages.MUTUAL_GUILDS_WITH_END_COUNT", // Lazy-loaded
|
||||
replacement: {
|
||||
match: /\.body.+?displayProfile:\i}\),/,
|
||||
replace: "$&$self.patchModal(arguments[0]),",
|
||||
|
|
|
@ -155,7 +155,7 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
|||
},
|
||||
kemo: {
|
||||
name: "kemo",
|
||||
id: 299693897859465228n
|
||||
id: 715746190813298788n
|
||||
},
|
||||
dzshn: {
|
||||
name: "dzshn",
|
||||
|
@ -425,6 +425,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
|||
newwares: {
|
||||
name: "newwares",
|
||||
id: 421405303951851520n
|
||||
},
|
||||
Byron: {
|
||||
name: "byeoon",
|
||||
id: 1167275288036655133n
|
||||
}
|
||||
} satisfies Record<string, Dev>);
|
||||
|
||||
|
|
|
@ -116,8 +116,11 @@ export function proxyLazy<T>(factory: () => T, attempts = 5, isChild = false): T
|
|||
attempts,
|
||||
true
|
||||
);
|
||||
|
||||
return Reflect.get(target[kGET](), p, receiver);
|
||||
const lazyTarget = target[kGET]();
|
||||
if (typeof lazyTarget === "object" || typeof lazyTarget === "function") {
|
||||
return Reflect.get(lazyTarget, p, receiver);
|
||||
}
|
||||
throw new Error("proxyLazy called on a primitive value");
|
||||
}
|
||||
}) as any;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue