From 52839c23068ce926ec32d302b2a8c109587d01f7 Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Tue, 27 Jun 2023 17:54:28 +0200 Subject: [PATCH] update_virtual_branch to VirtualBranchesStore --- .../projects_new/[projectId]/BranchLane.svelte | 7 +------ src/routes/projects_new/[projectId]/vbranches.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/routes/projects_new/[projectId]/BranchLane.svelte b/src/routes/projects_new/[projectId]/BranchLane.svelte index f4dc6a7e1..77021a3c1 100644 --- a/src/routes/projects_new/[projectId]/BranchLane.svelte +++ b/src/routes/projects_new/[projectId]/BranchLane.svelte @@ -37,11 +37,6 @@ return invoke('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>) { 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); } diff --git a/src/routes/projects_new/[projectId]/vbranches.ts b/src/routes/projects_new/[projectId]/vbranches.ts index 8d30e456d..2d3a70e64 100644 --- a/src/routes/projects_new/[projectId]/vbranches.ts +++ b/src/routes/projects_new/[projectId]/vbranches.ts @@ -15,6 +15,7 @@ export interface VirtualBranchStore { createBranch: (name: string, path: string) => Promise; commitBranch: (branch: string, message: string) => Promise; updateBranchTarget: () => Promise; + updateBranchName: (branchId: string, name: string) => Promise; } 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('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);