mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-03-17 03:47:26 +00:00
refactor(git-panel): simplify setCommitMessage with plain function
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Check, ChevronDown, GitCommit, RefreshCw, Sparkles } from 'lucide-react';
|
import { Check, ChevronDown, GitCommit, RefreshCw, Sparkles } from 'lucide-react';
|
||||||
import { useCallback, useState } from 'react';
|
import { useState } from 'react';
|
||||||
import MicButton from '../../../mic-button/view/MicButton';
|
import MicButton from '../../../mic-button/view/MicButton';
|
||||||
import type { ConfirmationRequest } from '../../types/types';
|
import type { ConfirmationRequest } from '../../types/types';
|
||||||
|
|
||||||
@@ -25,19 +25,17 @@ export default function CommitComposer({
|
|||||||
onGenerateMessage,
|
onGenerateMessage,
|
||||||
onRequestConfirmation,
|
onRequestConfirmation,
|
||||||
}: CommitComposerProps) {
|
}: CommitComposerProps) {
|
||||||
const [commitMessage, setCommitMessageState] = useState(() => commitMessageCache.get(projectPath) ?? '');
|
const [commitMessage, setCommitMessageRaw] = useState(() => commitMessageCache.get(projectPath) ?? '');
|
||||||
|
|
||||||
|
const setCommitMessage = (msg: string) => {
|
||||||
|
setCommitMessageRaw(msg);
|
||||||
|
if (msg) {
|
||||||
|
commitMessageCache.set(projectPath, msg);
|
||||||
|
} else {
|
||||||
|
commitMessageCache.delete(projectPath);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const setCommitMessage = useCallback(
|
|
||||||
(msg: string) => {
|
|
||||||
setCommitMessageState(msg);
|
|
||||||
if (msg) {
|
|
||||||
commitMessageCache.set(projectPath, msg);
|
|
||||||
} else {
|
|
||||||
commitMessageCache.delete(projectPath);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[projectPath],
|
|
||||||
);
|
|
||||||
const [isCommitting, setIsCommitting] = useState(false);
|
const [isCommitting, setIsCommitting] = useState(false);
|
||||||
const [isGeneratingMessage, setIsGeneratingMessage] = useState(false);
|
const [isGeneratingMessage, setIsGeneratingMessage] = useState(false);
|
||||||
const [isCollapsed, setIsCollapsed] = useState(isMobile);
|
const [isCollapsed, setIsCollapsed] = useState(isMobile);
|
||||||
|
|||||||
Reference in New Issue
Block a user