mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
refactor: extract repeated event value extraction pattern into helper function
- Add extractEventValue helper function to reduce code duplication - Replace 5 occurrences of repeated pattern with helper function call - Improves code readability and maintainability Addresses ellipsi-bot feedback about repeated pattern: (e as unknown as CustomEvent)?.detail?.target?.value || ((e as any).target as HTMLTextAreaElement).value
This commit is contained in:
parent
3b726a284b
commit
043e35fbce
1 changed files with 10 additions and 15 deletions
|
|
@ -63,6 +63,11 @@ function getGroupName(group: GroupEntry): ToolGroup {
|
|||
return Array.isArray(group) ? group[0] : group
|
||||
}
|
||||
|
||||
// Helper function to extract value from VSCode events (CustomEvent or regular Event)
|
||||
function extractEventValue(e: Event | React.FormEvent<HTMLElement>): string {
|
||||
return (e as unknown as CustomEvent)?.detail?.target?.value || ((e as any).target as HTMLTextAreaElement).value
|
||||
}
|
||||
|
||||
const ModesView = ({ onDone }: ModesViewProps) => {
|
||||
const { t } = useAppTranslation()
|
||||
|
||||
|
|
@ -859,9 +864,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
|
|||
setLocalModeRoleDefinition(currentValue)
|
||||
}}
|
||||
onChange={(e) => {
|
||||
const value =
|
||||
(e as unknown as CustomEvent)?.detail?.target?.value ||
|
||||
((e as any).target as HTMLTextAreaElement).value
|
||||
const value = extractEventValue(e)
|
||||
setLocalModeRoleDefinition(value)
|
||||
}}
|
||||
onBlur={() => {
|
||||
|
|
@ -942,9 +945,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
|
|||
setLocalModeDescription(currentValue || "")
|
||||
}}
|
||||
onChange={(e) => {
|
||||
const value =
|
||||
(e as unknown as CustomEvent)?.detail?.target?.value ||
|
||||
((e as any).target as HTMLTextAreaElement).value
|
||||
const value = extractEventValue(e)
|
||||
setLocalModeDescription(value)
|
||||
}}
|
||||
onBlur={() => {
|
||||
|
|
@ -1026,9 +1027,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
|
|||
setLocalModeWhenToUse(currentValue || "")
|
||||
}}
|
||||
onChange={(e) => {
|
||||
const value =
|
||||
(e as unknown as CustomEvent)?.detail?.target?.value ||
|
||||
((e as any).target as HTMLTextAreaElement).value
|
||||
const value = extractEventValue(e)
|
||||
setLocalModeWhenToUse(value)
|
||||
}}
|
||||
onBlur={() => {
|
||||
|
|
@ -1214,9 +1213,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
|
|||
setLocalModeCustomInstructions(currentValue || "")
|
||||
}}
|
||||
onChange={(e) => {
|
||||
const value =
|
||||
(e as unknown as CustomEvent)?.detail?.target?.value ||
|
||||
((e as any).target as HTMLTextAreaElement).value
|
||||
const value = extractEventValue(e)
|
||||
setLocalModeCustomInstructions(value)
|
||||
}}
|
||||
onBlur={() => {
|
||||
|
|
@ -1431,9 +1428,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
|
|||
resize="vertical"
|
||||
value={customInstructions || ""}
|
||||
onChange={(e) => {
|
||||
const value =
|
||||
(e as unknown as CustomEvent)?.detail?.target?.value ||
|
||||
((e as any).target as HTMLTextAreaElement).value
|
||||
const value = extractEventValue(e)
|
||||
setCustomInstructions(value || undefined)
|
||||
vscode.postMessage({
|
||||
type: "customInstructions",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue