Skip to content

Commit

Permalink
feat(playground): refine opened files
Browse files Browse the repository at this point in the history
  • Loading branch information
baurine committed Jun 21, 2024
1 parent 1002b8d commit 6900e1e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/playground/src/components/biz/files-panel/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,14 @@ function RenameFileDialog() {

function DelFileAlertDialog() {
const {
state: { allFiles, setAllFiles, activeFileId, setActiveFileId },
state: {
allFiles,
setAllFiles,
activeFileId,
setActiveFileId,
openedFiles,
setOpenedFiles
},
api: { delFile }
} = useFilesContext()

Expand All @@ -174,7 +181,11 @@ function DelFileAlertDialog() {
}
await delFile(activeFileId)
setAllFiles((pre) => pre.filter((f) => f.id !== activeFileId))
setActiveFileId(null)

const nextOpenedFiles = openedFiles.filter((f) => f.id !== activeFileId)
setOpenedFiles(nextOpenedFiles)

setActiveFileId(nextOpenedFiles[0]?.id ?? null)
}

const queryClient = useQueryClient()
Expand Down

0 comments on commit 6900e1e

Please sign in to comment.