aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorJustice Almanzar <superdash993@gmail.com>2022-12-02 10:43:37 -0500
committerGitHub <noreply@github.com>2022-12-02 16:43:37 +0100
commit41dddc9eee6f19fb5055545811aff1e282790a9c (patch)
treebf38148e87242e169adfa39919aa636a9d0551ce /src/api
parent4760af7f0ee275caa1eee440f4945032057d2b56 (diff)
downloadVencord-41dddc9eee6f19fb5055545811aff1e282790a9c.tar.gz
Vencord-41dddc9eee6f19fb5055545811aff1e282790a9c.tar.bz2
Vencord-41dddc9eee6f19fb5055545811aff1e282790a9c.zip
feat(plugin): ShikiCodeblocks (#267)
Co-authored-by: ArjixWasTaken <53124886+ArjixWasTaken@users.noreply.github.com> Co-authored-by: Ven <vendicated@riseup.net>
Diffstat (limited to 'src/api')
-rw-r--r--src/api/settings.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/api/settings.ts b/src/api/settings.ts
index b7c143a..2617903 100644
--- a/src/api/settings.ts
+++ b/src/api/settings.ts
@@ -141,14 +141,19 @@ export const Settings = makeProxy(settings);
* Settings hook for React components. Returns a smart settings
* object that automagically triggers a rerender if any properties
* are altered
+ * @param paths An optional list of paths to whitelist for rerenders
* @returns Settings
*/
-export function useSettings() {
+export function useSettings(paths?: string[]) {
const [, forceUpdate] = React.useReducer(() => ({}), {});
+ const onUpdate: SubscriptionCallback = paths
+ ? (value, path) => paths.includes(path) && forceUpdate()
+ : forceUpdate;
+
React.useEffect(() => {
- subscriptions.add(forceUpdate);
- return () => void subscriptions.delete(forceUpdate);
+ subscriptions.add(onUpdate);
+ return () => void subscriptions.delete(onUpdate);
}, []);
return Settings;