simplify plugin installation query hook

This commit is contained in:
yyh 2025-12-26 17:15:29 +08:00
parent ca490d84ff
commit f47c9be102
No known key found for this signature in database
1 changed files with 1 additions and 27 deletions

View File

@ -184,7 +184,7 @@ const parseAsBundleInfo = createParser<BundleInfoQuery>({
* setInstallState(null) // Clears installation params
*/
export function usePluginInstallation() {
const [installState, setInstallStateState] = useQueryStates(
return useQueryStates(
{
packageId: parseAsPackageId,
bundleInfo: parseAsBundleInfo,
@ -196,32 +196,6 @@ export function usePluginInstallation() {
},
},
)
const setInstallState = useCallback(
(state: { packageId?: string, bundleInfo?: BundleInfoQuery } | null) => {
if (!state) {
setInstallStateState(null)
return
}
const patch: { packageId?: string, bundleInfo?: BundleInfoQuery } = {}
if (state.packageId)
patch.packageId = state.packageId
if (state.bundleInfo)
patch.bundleInfo = state.bundleInfo
if (Object.keys(patch).length === 0)
return
setInstallStateState(patch)
},
[setInstallStateState],
)
return [
{
packageId: installState.packageId,
bundleInfo: installState.bundleInfo,
},
setInstallState,
] as const
}
/**