BetterNotes: Fix patches

This commit is contained in:
Nuckyz 2024-03-22 09:42:19 -03:00
parent ca18b6e044
commit 8d35cc6112
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -18,6 +18,7 @@
import { Settings } from "@api/Settings"; import { Settings } from "@api/Settings";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { canonicalizeMatch } from "@utils/patches";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy } from "@webpack"; import { findByPropsLazy } from "@webpack";
@ -39,8 +40,12 @@ export default definePlugin({
match: /hideNote:.+?(?=([,}].*?\)))/g, match: /hideNote:.+?(?=([,}].*?\)))/g,
replace: (m, rest) => { replace: (m, rest) => {
const destructuringMatch = rest.match(/}=.+/); const destructuringMatch = rest.match(/}=.+/);
if (destructuringMatch == null) return "hideNote:!0"; if (destructuringMatch) {
return m; const defaultValueMatch = m.match(canonicalizeMatch(/hideNote:(\i)=!?\d/));
return defaultValueMatch ? `hideNote:${defaultValueMatch[1]}=!0` : m;
}
return "hideNote:!0";
} }
} }
}, },
@ -52,10 +57,10 @@ export default definePlugin({
} }
}, },
{ {
find: ".Messages.NOTE}", find: ".popularApplicationCommandIds,",
replacement: { replacement: {
match: /(?<=return \i\?)null(?=:\(0,\i\.jsxs)/, match: /lastSection:(!?\i)}\),/,
replace: "$self.patchPadding(arguments[0])" replace: "$&$self.patchPadding($1),"
} }
} }
], ],
@ -75,8 +80,8 @@ export default definePlugin({
} }
}, },
patchPadding(e: any) { patchPadding(lastSection: any) {
if (!e.lastSection) return; if (!lastSection) return;
return ( return (
<div className={UserPopoutSectionCssClasses.lastSection}></div> <div className={UserPopoutSectionCssClasses.lastSection}></div>
); );