mirror of
https://github.com/Equicord/Equicord.git
synced 2025-01-18 13:23:28 -05:00
Merge remote-tracking branch 'upstream/dev'
This commit is contained in:
commit
cdeb34b5f2
7 changed files with 35 additions and 18 deletions
|
@ -82,7 +82,7 @@
|
||||||
"zip-local": "^0.3.5",
|
"zip-local": "^0.3.5",
|
||||||
"zustand": "^3.7.2"
|
"zustand": "^3.7.2"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@8.10.2",
|
"packageManager": "pnpm@9.1.0",
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"eslint@8.46.0": "patches/eslint@8.46.0.patch",
|
"eslint@8.46.0": "patches/eslint@8.46.0.patch",
|
||||||
|
|
|
@ -25,10 +25,11 @@ import { access, readdir, readFile } from "fs/promises";
|
||||||
import { join, relative } from "path";
|
import { join, relative } from "path";
|
||||||
import { promisify } from "util";
|
import { promisify } from "util";
|
||||||
|
|
||||||
// wtf is this assert syntax
|
|
||||||
import PackageJSON from "../../package.json" assert { type: "json" };
|
|
||||||
import { getPluginTarget } from "../utils.mjs";
|
import { getPluginTarget } from "../utils.mjs";
|
||||||
|
|
||||||
|
/** @type {import("../../package.json")} */
|
||||||
|
const PackageJSON = JSON.parse(readFileSync("package.json"));
|
||||||
|
|
||||||
export const VERSION = PackageJSON.version;
|
export const VERSION = PackageJSON.version;
|
||||||
// https://reproducible-builds.org/docs/source-date-epoch/
|
// https://reproducible-builds.org/docs/source-date-epoch/
|
||||||
export const BUILD_TIMESTAMP = Number(process.env.SOURCE_DATE_EPOCH) || Date.now();
|
export const BUILD_TIMESTAMP = Number(process.env.SOURCE_DATE_EPOCH) || Date.now();
|
||||||
|
|
|
@ -166,10 +166,13 @@ const settings = definePluginSettings({
|
||||||
description: "What text the hyperlink should use. {{NAME}} will be replaced with the emoji/sticker name.",
|
description: "What text the hyperlink should use. {{NAME}} will be replaced with the emoji/sticker name.",
|
||||||
type: OptionType.STRING,
|
type: OptionType.STRING,
|
||||||
default: "{{NAME}}"
|
default: "{{NAME}}"
|
||||||
|
},
|
||||||
|
disableEmbedPermissionCheck: {
|
||||||
|
description: "Whether to disable the embed permission check when sending fake emojis and stickers",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
}).withPrivateSettings<{
|
});
|
||||||
disableEmbedPermissionCheck: boolean;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
function hasPermission(channelId: string, permission: bigint) {
|
function hasPermission(channelId: string, permission: bigint) {
|
||||||
const channel = ChannelStore.getChannel(channelId);
|
const channel = ChannelStore.getChannel(channelId);
|
||||||
|
@ -397,6 +400,14 @@ export default definePlugin({
|
||||||
match: /(?<=type:"(?:SOUNDBOARD_SOUNDS_RECEIVED|GUILD_SOUNDBOARD_SOUND_CREATE|GUILD_SOUNDBOARD_SOUND_UPDATE|GUILD_SOUNDBOARD_SOUNDS_UPDATE)".+?available:)\i\.available/g,
|
match: /(?<=type:"(?:SOUNDBOARD_SOUNDS_RECEIVED|GUILD_SOUNDBOARD_SOUND_CREATE|GUILD_SOUNDBOARD_SOUND_UPDATE|GUILD_SOUNDBOARD_SOUNDS_UPDATE)".+?available:)\i\.available/g,
|
||||||
replace: "true"
|
replace: "true"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// Allow using custom notification sounds
|
||||||
|
{
|
||||||
|
find: "canUseCustomNotificationSounds:function",
|
||||||
|
replacement: {
|
||||||
|
match: /canUseCustomNotificationSounds:function\(\i\){/,
|
||||||
|
replace: "$&return true;"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ export const patches = [] as Patch[];
|
||||||
|
|
||||||
/** Whether we have subscribed to flux events of all the enabled plugins when FluxDispatcher was ready */
|
/** Whether we have subscribed to flux events of all the enabled plugins when FluxDispatcher was ready */
|
||||||
let enabledPluginsSubscribedFlux = false;
|
let enabledPluginsSubscribedFlux = false;
|
||||||
|
const subscribedFluxEventsPlugins = new Set<string>();
|
||||||
|
|
||||||
const settings = Settings.plugins;
|
const settings = Settings.plugins;
|
||||||
|
|
||||||
|
@ -123,7 +124,9 @@ export function startDependenciesRecursive(p: Plugin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function subscribePluginFluxEvents(p: Plugin, fluxDispatcher: typeof FluxDispatcher) {
|
export function subscribePluginFluxEvents(p: Plugin, fluxDispatcher: typeof FluxDispatcher) {
|
||||||
if (p.flux) {
|
if (p.flux && !subscribedFluxEventsPlugins.has(p.name)) {
|
||||||
|
subscribedFluxEventsPlugins.add(p.name);
|
||||||
|
|
||||||
logger.debug("Subscribing to flux events of plugin", p.name);
|
logger.debug("Subscribing to flux events of plugin", p.name);
|
||||||
for (const [event, handler] of Object.entries(p.flux)) {
|
for (const [event, handler] of Object.entries(p.flux)) {
|
||||||
fluxDispatcher.subscribe(event as FluxEvents, handler);
|
fluxDispatcher.subscribe(event as FluxEvents, handler);
|
||||||
|
@ -133,6 +136,8 @@ export function subscribePluginFluxEvents(p: Plugin, fluxDispatcher: typeof Flux
|
||||||
|
|
||||||
export function unsubscribePluginFluxEvents(p: Plugin, fluxDispatcher: typeof FluxDispatcher) {
|
export function unsubscribePluginFluxEvents(p: Plugin, fluxDispatcher: typeof FluxDispatcher) {
|
||||||
if (p.flux) {
|
if (p.flux) {
|
||||||
|
subscribedFluxEventsPlugins.delete(p.name);
|
||||||
|
|
||||||
logger.debug("Unsubscribing from flux events of plugin", p.name);
|
logger.debug("Unsubscribing from flux events of plugin", p.name);
|
||||||
for (const [event, handler] of Object.entries(p.flux)) {
|
for (const [event, handler] of Object.entries(p.flux)) {
|
||||||
fluxDispatcher.unsubscribe(event as FluxEvents, handler);
|
fluxDispatcher.unsubscribe(event as FluxEvents, handler);
|
||||||
|
|
|
@ -64,23 +64,15 @@ export let DraftStore: t.DraftStore;
|
||||||
/**
|
/**
|
||||||
* React hook that returns stateful data for one or more stores
|
* React hook that returns stateful data for one or more stores
|
||||||
* You might need a custom comparator (4th argument) if your store data is an object
|
* You might need a custom comparator (4th argument) if your store data is an object
|
||||||
*
|
|
||||||
* @param stores The stores to listen to
|
* @param stores The stores to listen to
|
||||||
* @param mapper A function that returns the data you need
|
* @param mapper A function that returns the data you need
|
||||||
* @param idk some thing, idk just pass null
|
* @param dependencies An array of reactive values which the hook depends on. Use this if your mapper or equality function depends on the value of another hook
|
||||||
* @param isEqual A custom comparator for the data returned by mapper
|
* @param isEqual A custom comparator for the data returned by mapper
|
||||||
*
|
*
|
||||||
* @example const user = useStateFromStores([UserStore], () => UserStore.getCurrentUser(), null, (old, current) => old.id === current.id);
|
* @example const user = useStateFromStores([UserStore], () => UserStore.getCurrentUser(), null, (old, current) => old.id === current.id);
|
||||||
*/
|
*/
|
||||||
export const { useStateFromStores }: {
|
// eslint-disable-next-line prefer-destructuring
|
||||||
useStateFromStores: <T>(
|
export const useStateFromStores: t.useStateFromStores = findByPropsLazy("useStateFromStores").useStateFromStores;
|
||||||
stores: t.FluxStore[],
|
|
||||||
mapper: () => T,
|
|
||||||
idk?: any,
|
|
||||||
isEqual?: (old: T, newer: T) => boolean
|
|
||||||
) => T;
|
|
||||||
}
|
|
||||||
= findByPropsLazy("useStateFromStores");
|
|
||||||
|
|
||||||
waitForStore("DraftStore", s => DraftStore = s);
|
waitForStore("DraftStore", s => DraftStore = s);
|
||||||
waitForStore("UserStore", s => UserStore = s);
|
waitForStore("UserStore", s => UserStore = s);
|
||||||
|
|
7
src/webpack/common/types/stores.d.ts
vendored
7
src/webpack/common/types/stores.d.ts
vendored
|
@ -182,3 +182,10 @@ export class GuildStore extends FluxStore {
|
||||||
getRoles(guildId: string): Record<string, Role>;
|
getRoles(guildId: string): Record<string, Role>;
|
||||||
getAllGuildRoles(): Record<string, Record<string, Role>>;
|
getAllGuildRoles(): Record<string, Record<string, Role>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type useStateFromStores = <T>(
|
||||||
|
stores: t.FluxStore[],
|
||||||
|
mapper: () => T,
|
||||||
|
dependencies?: any,
|
||||||
|
isEqual?: (old: T, newer: T) => boolean
|
||||||
|
) => T;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"resolveJsonModule": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
|
Loading…
Reference in a new issue