-
Notifications
You must be signed in to change notification settings - Fork 15
fix: wire account override to /files page #1650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: test
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import { usePrivy } from "@privy-io/react-auth"; | |
| import { getSandboxes } from "@/lib/sandboxes/getSandboxes"; | ||
| import { convertFileTreeEntries } from "@/lib/sandboxes/convertFileTreeEntries"; | ||
| import getSubtreeAtPath from "@/lib/sandboxes/getSubtreeAtPath"; | ||
| import { useAccountOverride } from "@/providers/AccountOverrideProvider"; | ||
| import type { Sandbox } from "@/lib/sandboxes/createSandbox"; | ||
| import type { FileNode } from "@/lib/sandboxes/parseFileTree"; | ||
|
|
||
|
|
@@ -17,15 +18,16 @@ interface UseSandboxesReturn { | |
|
|
||
| export default function useSandboxes(): UseSandboxesReturn { | ||
| const { getAccessToken, authenticated } = usePrivy(); | ||
| const { accountIdOverride } = useAccountOverride(); | ||
|
|
||
| const query = useQuery({ | ||
| queryKey: ["sandboxes"], | ||
| queryKey: ["sandboxes", accountIdOverride], | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This query now keys on Useful? React with 👍 / 👎. |
||
| queryFn: async () => { | ||
| const accessToken = await getAccessToken(); | ||
| if (!accessToken) { | ||
| throw new Error("Please sign in to view sandboxes"); | ||
| } | ||
| return getSandboxes(accessToken); | ||
| return getSandboxes(accessToken, accountIdOverride); | ||
| }, | ||
| enabled: authenticated, | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After wiring
accountIdOverrideintogetFileContents, this hook still retains priorselectedPathand mutation data across account switches, so changing override (or clearing it) can leaveSandboxFilePreviewshowing content fetched for the previous account until another file is clicked. Since this path is now account-scoped, clear/reset mutation state on override change (or key mutation state by account) to prevent stale cross-account previews.Useful? React with 👍 / 👎.