mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
refactor: extract skill save context, stabilize mutation dependency, and deduplicate cache updates
Split SkillSaveContext and useSkillSaveManager into a separate file to fix react-refresh/only-export-components lint error. Destructure mutateAsync from useUpdateAppAssetFileContent for a stable callback reference, preventing unnecessary useCallback cascade rebuilds. Extract shared patchFileContentCache helper to unify setQueryData logic between updateCachedContent and the collaboration event handler.
This commit is contained in:
@ -0,0 +1,19 @@
|
||||
import type { FallbackEntry, SaveFileOptions, SaveResult } from './use-skill-save-manager'
|
||||
import * as React from 'react'
|
||||
|
||||
type SkillSaveContextValue = {
|
||||
saveFile: (fileId: string, options?: SaveFileOptions) => Promise<SaveResult>
|
||||
saveAllDirty: () => void
|
||||
registerFallback: (fileId: string, entry: FallbackEntry) => void
|
||||
unregisterFallback: (fileId: string) => void
|
||||
}
|
||||
|
||||
export const SkillSaveContext = React.createContext<SkillSaveContextValue | null>(null)
|
||||
|
||||
export const useSkillSaveManager = () => {
|
||||
const context = React.useContext(SkillSaveContext)
|
||||
if (!context)
|
||||
throw new Error('Missing SkillSaveProvider in the tree')
|
||||
|
||||
return context
|
||||
}
|
||||
Reference in New Issue
Block a user