about summary refs log tree commit diff
path: root/src/state/preferences/autoplay.tsx
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-08-06 01:30:52 +0100
committerGitHub <noreply@github.com>2024-08-06 01:30:52 +0100
commit686d5ebb535710dd8c96aa694b4cd1f7913ff3fa (patch)
tree35ca7e7646d455468c97520b8cb972e8555fc3f2 /src/state/preferences/autoplay.tsx
parent966f6c511fff510fc011aa5c426c6b7eaf4f21ac (diff)
downloadvoidsky-686d5ebb535710dd8c96aa694b4cd1f7913ff3fa.tar.zst
[Persisted] Make broadcast subscriptions granular by key (#4874)
* Add fast path for guaranteed noop updates

* Change persisted.onUpdate() API to take a key

* Implement granular broadcast listeners
Diffstat (limited to 'src/state/preferences/autoplay.tsx')
-rw-r--r--src/state/preferences/autoplay.tsx4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/state/preferences/autoplay.tsx b/src/state/preferences/autoplay.tsx
index d5aa049f3..141c8161e 100644
--- a/src/state/preferences/autoplay.tsx
+++ b/src/state/preferences/autoplay.tsx
@@ -24,8 +24,8 @@ export function Provider({children}: {children: React.ReactNode}) {
   )
 
   React.useEffect(() => {
-    return persisted.onUpdate(() => {
-      setState(Boolean(persisted.get('disableAutoplay')))
+    return persisted.onUpdate('disableAutoplay', nextDisableAutoplay => {
+      setState(Boolean(nextDisableAutoplay))
     })
   }, [setStateWrapped])