* 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
32 lines
1.1 KiB
TypeScript
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()
|
|
}
|