Commit fb77bb1
authored
🤖 fix: workspace sidebar updates immediately on creation (#997)
The `useWorkspaceRecency` hook was subscribed to `states.subscribeAny`,
but workspace recency is bumped via `derived.bump("recency")`. This
caused a delay between workspace creation and the sidebar reflecting the
new workspace.
## Root Cause
When a workspace is created:
1. `addWorkspace` is called, which calls `this.derived.bump("recency")`
(line 731)
2. `useWorkspaceRecency` was subscribed to `store.subscribe` which
delegates to `states.subscribeAny`
3. Since recency is bumped on `derived`, not `states`, React wasn't
notified of the change
4. The sidebar would only update when some other action triggered a
`states` bump
## Fix
1. Added `subscribeDerived` method to `WorkspaceStore` that exposes
`derived.subscribeAny`
2. Updated `useWorkspaceRecency` to use `subscribeDerived` instead of
`subscribe`
Now when `derived.bump("recency")` is called, the subscription fires
immediately and React re-renders the sidebar with the new workspace.
_Generated with `mux`_1 parent 404b3e8 commit fb77bb1
1 file changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
404 | 410 | | |
405 | 411 | | |
406 | 412 | | |
| |||
1087 | 1093 | | |
1088 | 1094 | | |
1089 | 1095 | | |
| 1096 | + | |
1090 | 1097 | | |
1091 | 1098 | | |
1092 | 1099 | | |
1093 | 1100 | | |
1094 | | - | |
| 1101 | + | |
1095 | 1102 | | |
1096 | 1103 | | |
1097 | 1104 | | |
| |||
0 commit comments