Fix some Context Menus being broken by regression
This commit is contained in:
parent
7f54858b27
commit
4abce9d084
2 changed files with 11 additions and 5 deletions
|
@ -35,7 +35,7 @@ function makeSettingsListenerHelpers<O extends object>(o: SettingsStore<O>) {
|
|||
listeners.set(cb, path);
|
||||
o.addChangeListener(path, cb);
|
||||
};
|
||||
const removeListener = () => {
|
||||
const removeAllListeners = () => {
|
||||
for (const [listener, path] of listeners) {
|
||||
o.removeChangeListener(path as any, listener);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ function makeSettingsListenerHelpers<O extends object>(o: SettingsStore<O>) {
|
|||
listeners.clear();
|
||||
};
|
||||
|
||||
return [addListener, removeListener] as const;
|
||||
return [addListener, removeAllListeners] as const;
|
||||
}
|
||||
|
||||
const [addSettingsListener, removeSettingsListeners] = makeSettingsListenerHelpers(Settings);
|
||||
|
|
|
@ -22,14 +22,20 @@ addPatch({
|
|||
find: ".enableSpellCheck)",
|
||||
replacement: {
|
||||
// if (isDesktop) { DiscordNative.onSpellcheck(openMenu(props)) } else { e.preventDefault(); openMenu(props) }
|
||||
match: /else\{.{1,3}\.preventDefault\(\);(.{1,3}\(.{1,3}\))\}/,
|
||||
match: /else\{(.{1,3})\.preventDefault\(\);(.{1,3}\(.{1,3}\))\}(?<=:(.{1,3})\.enableSpellCheck\).+?)/,
|
||||
// ... else { $self.onSlateContext(() => openMenu(props)) }
|
||||
replace: "else {$self.onSlateContext(() => $1)}"
|
||||
replace: "else {$self.onSlateContext($1, $3?.enableSpellCheck, () => $2)}"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
onSlateContext(openMenu: () => void) {
|
||||
onSlateContext(e: MouseEvent, hasSpellcheck: boolean | undefined, openMenu: () => void) {
|
||||
if (!hasSpellcheck) {
|
||||
e.preventDefault();
|
||||
openMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
const cb = (w: string, c: string[]) => {
|
||||
VencordDesktopNative.spellcheck.offSpellcheckResult(cb);
|
||||
word = w;
|
||||
|
|
Loading…
Reference in a new issue