Files
cline-multi-mirror/src/core/controller/state/updateAutoApprovalSettings.ts
T
celestial-vault 669e018b85 Move rest of state to cache (#5404)
* move rest of state to cacheService

* finish moving state to cache

* remove console logs

* fix types

* don't type cast

* add eslint rule banning use of direct storage apis

* fix types

* move vscode state eslint rule to separate rule since it's error and the others aren't

* fix eslint rules parsing
2025-08-11 14:46:39 -07:00

32 lines
1.1 KiB
TypeScript

import { Controller } from ".."
import { AutoApprovalSettingsRequest } from "@shared/proto/cline/state"
import { Empty } from "@shared/proto/cline/common"
import { convertProtoToAutoApprovalSettings } from "../../../shared/proto-conversions/models/auto-approval-settings-conversion"
/**
* Updates the auto approval settings
* @param controller The controller instance
* @param request The auto approval settings request
* @returns Empty response
*/
export async function updateAutoApprovalSettings(controller: Controller, request: AutoApprovalSettingsRequest): Promise<Empty> {
const currentSettings = (await controller.getStateToPostToWebview()).autoApprovalSettings
const incomingVersion = request.version
const currentVersion = currentSettings?.version ?? 1
// Only update if incoming version is higher
if (incomingVersion > currentVersion) {
const settings = convertProtoToAutoApprovalSettings(request)
controller.cacheService.setGlobalState("autoApprovalSettings", settings)
if (controller.task) {
controller.task.updateAutoApprovalSettings(settings)
}
await controller.postStateToWebview()
}
return Empty.create()
}