mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-03 23:18:26 +03:00
update_virtual_branch to VirtualBranchesStore
This commit is contained in:
parent
59ddd5cf39
commit
52839c2306
@ -37,11 +37,6 @@
|
||||
return invoke<object>('move_virtual_branch_files', params);
|
||||
}
|
||||
|
||||
const update_branch = async (params: {
|
||||
projectId: string;
|
||||
branch: { id: string; name: string };
|
||||
}) => invoke('update_virtual_branch', params);
|
||||
|
||||
function handleDndEvent(e: CustomEvent<DndEvent<File | Hunk>>) {
|
||||
const newItems = e.detail.items;
|
||||
const fileItems = newItems.filter((item) => item instanceof File) as File[];
|
||||
@ -123,7 +118,7 @@
|
||||
|
||||
function handleBranchNameChange() {
|
||||
console.log('branch name change:', name);
|
||||
update_branch({ projectId: projectId, branch: { id: branchId, name: name } });
|
||||
virtualBranches.updateBranchName(branchId, name);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -15,6 +15,7 @@ export interface VirtualBranchStore {
|
||||
createBranch: (name: string, path: string) => Promise<void | object>;
|
||||
commitBranch: (branch: string, message: string) => Promise<void | object>;
|
||||
updateBranchTarget: () => Promise<void | object>;
|
||||
updateBranchName: (branchId: string, name: string) => Promise<void | object>;
|
||||
}
|
||||
|
||||
export function getStore(projectId: string): VirtualBranchStore {
|
||||
@ -66,6 +67,20 @@ export function getStore(projectId: string): VirtualBranchStore {
|
||||
console.log(err);
|
||||
error('Unable to update target!');
|
||||
});
|
||||
},
|
||||
updateBranchName(branchId, name) {
|
||||
return invoke<object>('update_virtual_branch', {
|
||||
projectId: projectId,
|
||||
branch: { id: branchId, name: name }
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
refresh(projectId, writeable);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
error('Unable to update branch!');
|
||||
});
|
||||
}
|
||||
};
|
||||
cache.set(projectId, store);
|
||||
|
Loading…
Reference in New Issue
Block a user