From 75b086f12b1493d64f692e0274d684552e281dc5 Mon Sep 17 00:00:00 2001 From: Mattias Granlund Date: Sun, 25 Jun 2023 15:33:20 +0300 Subject: [PATCH] Update branches on commit/new branch --- .../projects_new/[projectId]/+page.svelte | 5 ++- src/routes/projects_new/[projectId]/+page.ts | 22 +--------- .../projects_new/[projectId]/Board.svelte | 41 ++++++++++++++++--- .../[projectId]/BranchLane.svelte | 29 +++++++------ .../[projectId]/NewBranchDropZone.svelte | 1 + 5 files changed, 59 insertions(+), 39 deletions(-) diff --git a/src/routes/projects_new/[projectId]/+page.svelte b/src/routes/projects_new/[projectId]/+page.svelte index 76a2aa5ef..1f6c41c60 100644 --- a/src/routes/projects_new/[projectId]/+page.svelte +++ b/src/routes/projects_new/[projectId]/+page.svelte @@ -6,7 +6,8 @@ import { invoke } from '@tauri-apps/api'; export let data: PageData; - let { projectId, target, branches, remoteBranches, remoteBranchesData } = data; + let { projectId, target, remoteBranches, remoteBranchesData } = data; + let branches: Branch[] = []; let targetChoice = 'origin/master'; // prob should check if it exists async function setTarget() { @@ -31,7 +32,7 @@ {#if target}
- +
{:else}
diff --git a/src/routes/projects_new/[projectId]/+page.ts b/src/routes/projects_new/[projectId]/+page.ts index 6c78bc229..dbb6049a6 100644 --- a/src/routes/projects_new/[projectId]/+page.ts +++ b/src/routes/projects_new/[projectId]/+page.ts @@ -1,12 +1,7 @@ -import { plainToInstance } from 'class-transformer'; -import { Target, Branch, type BranchData } from './types'; +import type { Target, BranchData } from './types'; import { invoke } from '$lib/ipc'; import type { PageLoadEvent } from './$types'; -async function getVirtualBranches(params: { projectId: string }) { - return invoke>('list_virtual_branches', params); -} - async function getRemoteBranches(params: { projectId: string }) { return invoke>('git_remote_branches', params); } @@ -19,15 +14,6 @@ async function getRemoteBranchesData(params: { projectId: string }) { return invoke>('git_remote_branches_data', params); } -function sortBranchHunks(branches: Branch[]): Branch[] { - for (const branch of branches) { - for (const file of branch.files) { - file.hunks.sort((a, b) => b.modifiedAt.getTime() - a.modifiedAt.getTime()); - } - } - return branches; -} - function sortBranchData(branchData: BranchData[]): BranchData[] { // sort remote_branches_data by date return branchData.sort((a, b) => b.lastCommitTs - a.lastCommitTs); @@ -38,11 +24,7 @@ export async function load(e: PageLoadEvent) { const target = await getTargetData({ projectId }); const remoteBranches = await getRemoteBranches({ projectId }); const remoteBranchesData = sortBranchData(await getRemoteBranchesData({ projectId })); - const branches: Branch[] = sortBranchHunks( - plainToInstance(Branch, await getVirtualBranches({ projectId })) - ); - console.log(branches); - return { projectId, target, remoteBranches, remoteBranchesData, branches }; + return { projectId, target, remoteBranches, remoteBranchesData }; } if (import.meta.vitest) { diff --git a/src/routes/projects_new/[projectId]/Board.svelte b/src/routes/projects_new/[projectId]/Board.svelte index 982e1923b..829990526 100644 --- a/src/routes/projects_new/[projectId]/Board.svelte +++ b/src/routes/projects_new/[projectId]/Board.svelte @@ -1,17 +1,31 @@ -
{/each} - +