From 4beef9f73be01716a9e5dc880e28afd0c821a571 Mon Sep 17 00:00:00 2001 From: megumin Date: Wed, 25 Oct 2023 13:39:57 +0100 Subject: [PATCH] fix: ComponentDispatch and GifPaste plugin (#1843) Co-authored-by: V --- .eslintrc.json | 5 ++++- src/plugins/gifPaste/index.ts | 2 +- src/webpack/common/utils.ts | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 8fa3386a..2ee24e8b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -51,7 +51,10 @@ "eqeqeq": ["error", "always", { "null": "ignore" }], "spaced-comment": ["error", "always", { "markers": ["!"] }], "yoda": "error", - "prefer-destructuring": ["error", { "object": true, "array": false }], + "prefer-destructuring": ["error", { + "VariableDeclarator": { "array": false, "object": true }, + "AssignmentExpression": { "array": false, "object": false } + }], "operator-assignment": ["error", "always"], "no-useless-computed-key": "error", "no-unneeded-ternary": ["error", { "defaultAssignment": false }], diff --git a/src/plugins/gifPaste/index.ts b/src/plugins/gifPaste/index.ts index f1dfb2ff..8c1303ba 100644 --- a/src/plugins/gifPaste/index.ts +++ b/src/plugins/gifPaste/index.ts @@ -33,7 +33,7 @@ export default definePlugin({ patches: [{ find: ".handleSelectGIF=", replacement: { - match: /\.handleSelectGIF=function.+?\{/, + match: /\.handleSelectGIF=\i=>\{/, replace: ".handleSelectGIF=function(gif){return $self.handleSelect(gif);" } }], diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index bc97f5e7..25fda58b 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -24,7 +24,9 @@ import { _resolveReady, filters, find, findByCodeLazy, findByPropsLazy, findLazy import type * as t from "./types/utils"; export let FluxDispatcher: t.FluxDispatcher; -export const ComponentDispatch = findLazy(m => m.emitter?._events?.INSERT_TEXT); +export let ComponentDispatch; +waitFor(["ComponentDispatch", "ComponentDispatcher"], m => ComponentDispatch = m.ComponentDispatch); + export const RestAPI: t.RestAPI = findByPropsLazy("getAPIBaseURL", "get"); export const moment: typeof import("moment") = findByPropsLazy("parseTwoDigitYear");