From 0a4594573821d35ab209b3f7fc80a179b276c988 Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Tue, 27 Jun 2023 09:43:32 +0200 Subject: [PATCH] changed my mind about union types --- src/routes/projects_new/[projectId]/+page.svelte | 13 ++++++------- src/routes/projects_new/[projectId]/Board.svelte | 4 ++-- src/routes/projects_new/[projectId]/vbranches.ts | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/routes/projects_new/[projectId]/+page.svelte b/src/routes/projects_new/[projectId]/+page.svelte index f5dbc3de9..b8c5e9549 100644 --- a/src/routes/projects_new/[projectId]/+page.svelte +++ b/src/routes/projects_new/[projectId]/+page.svelte @@ -5,16 +5,15 @@ import type { Branch } from './types'; import { invoke } from '@tauri-apps/api'; import vbranches from './vbranches'; - import { Value, Loadable } from 'svelte-loadable-store'; - import type { Readable } from '@square/svelte-store'; + import { Value } from 'svelte-loadable-store'; export let data: PageData; let { projectId, target, remoteBranches, remoteBranchesData } = data; - const branchStore = vbranches(projectId) as Readable>; - $: branches = $branchStore.isLoading + const virtualBranches = vbranches(projectId); + $: branches = $virtualBranches.isLoading ? [] - : Value.isValue($branchStore.value) - ? $branchStore.value + : Value.isValue($virtualBranches.value) + ? $virtualBranches.value : []; let targetChoice = 'origin/master'; // prob should check if it exists @@ -40,7 +39,7 @@ {#if target}
- +
{:else}
diff --git a/src/routes/projects_new/[projectId]/Board.svelte b/src/routes/projects_new/[projectId]/Board.svelte index 678bcc153..8b02d7e33 100644 --- a/src/routes/projects_new/[projectId]/Board.svelte +++ b/src/routes/projects_new/[projectId]/Board.svelte @@ -9,7 +9,7 @@ export let projectId: string; export let branches: Branch[]; - export let branchStore: VirtualBrancher; + export let virtualBranches: VirtualBrancher; const dispatch = createEventDispatcher(); const newBranchClass = 'new-branch-active'; @@ -31,7 +31,7 @@ function handleUpdateRequest() { // TODO: pass this as prop to components and refresh whenever we perform updates - branchStore.refresh(); + virtualBranches.refresh(); } diff --git a/src/routes/projects_new/[projectId]/vbranches.ts b/src/routes/projects_new/[projectId]/vbranches.ts index b9dec6ba2..021355113 100644 --- a/src/routes/projects_new/[projectId]/vbranches.ts +++ b/src/routes/projects_new/[projectId]/vbranches.ts @@ -6,7 +6,7 @@ import { plainToInstance } from 'class-transformer'; import type { Readable, Writable } from '@square/svelte-store'; /** Virtual Branch interface with custom operations on top of subscribing */ -export interface VirtualBrancher { +export interface VirtualBrancher extends Readable> { /** * Force re-fetch of the branches. Exists temporarily until we have all mutations on this interface. */ @@ -16,7 +16,7 @@ export interface VirtualBrancher { const cache: Record>> = {}; -export default (projectId: string): VirtualBrancher | Readable> => { +export default (projectId: string): VirtualBrancher => { if (projectId in cache) { const store = cache[projectId]; return {