fix(git-panel): handle promise rejection in branch creation and return success status

This commit is contained in:
Haileyesus
2026-02-23 10:37:28 +03:00
parent f1fd9b2f87
commit dad3ed6d86

View File

@@ -24,16 +24,22 @@ export default function NewBranchModal({
} }
}, [isOpen]); }, [isOpen]);
const handleCreateBranch = async () => { const handleCreateBranch = async (): Promise<boolean> => {
const branchName = newBranchName.trim(); const branchName = newBranchName.trim();
if (!branchName) { if (!branchName) {
return; return false;
} }
const success = await onCreateBranch(branchName); try {
if (success) { const success = await onCreateBranch(branchName);
setNewBranchName(''); if (success) {
onClose(); setNewBranchName('');
onClose();
}
return success;
} catch (error) {
console.error('Failed to create branch:', error);
return false;
} }
}; };