chore: toast on file load error
This commit is contained in:
parent
d2da59f844
commit
7466c08277
1 changed files with 21 additions and 11 deletions
|
|
@ -9,6 +9,7 @@ import { base64Encode } from "@opencode-ai/util/encode"
|
||||||
import { useProviders } from "@/hooks/use-providers"
|
import { useProviders } from "@/hooks/use-providers"
|
||||||
import { DateTime } from "luxon"
|
import { DateTime } from "luxon"
|
||||||
import { persisted } from "@/utils/persist"
|
import { persisted } from "@/utils/persist"
|
||||||
|
import { showToast } from "@opencode-ai/ui/toast"
|
||||||
|
|
||||||
export type LocalFile = FileNode &
|
export type LocalFile = FileNode &
|
||||||
Partial<{
|
Partial<{
|
||||||
|
|
@ -336,17 +337,26 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
|
||||||
|
|
||||||
const load = async (path: string) => {
|
const load = async (path: string) => {
|
||||||
const relativePath = relative(path)
|
const relativePath = relative(path)
|
||||||
await sdk.client.file.read({ path: relativePath }).then((x) => {
|
await sdk.client.file
|
||||||
if (!store.node[relativePath]) return
|
.read({ path: relativePath })
|
||||||
setStore(
|
.then((x) => {
|
||||||
"node",
|
if (!store.node[relativePath]) return
|
||||||
relativePath,
|
setStore(
|
||||||
produce((draft) => {
|
"node",
|
||||||
draft.loaded = true
|
relativePath,
|
||||||
draft.content = x.data
|
produce((draft) => {
|
||||||
}),
|
draft.loaded = true
|
||||||
)
|
draft.content = x.data
|
||||||
})
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
showToast({
|
||||||
|
variant: "error",
|
||||||
|
title: "Failed to load file",
|
||||||
|
description: e.message,
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetch = async (path: string) => {
|
const fetch = async (path: string) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue