From e0d889dd8589612d882c8e39b4e97182a74432d2 Mon Sep 17 00:00:00 2001 From: Mattias Granlund Date: Tue, 28 Nov 2023 20:41:06 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20sleep=20function=20to?= =?UTF-8?q?=20delay=20PR=20creation=20after=20pushing=20branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/src/lib/utils/sleep.ts | 3 +++ .../src/routes/[projectId]/components/LocalCommits.svelte | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 packages/ui/src/lib/utils/sleep.ts diff --git a/packages/ui/src/lib/utils/sleep.ts b/packages/ui/src/lib/utils/sleep.ts new file mode 100644 index 000000000..2df63d3ee --- /dev/null +++ b/packages/ui/src/lib/utils/sleep.ts @@ -0,0 +1,3 @@ +export function sleep(ms: number) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} diff --git a/packages/ui/src/routes/[projectId]/components/LocalCommits.svelte b/packages/ui/src/routes/[projectId]/components/LocalCommits.svelte index 8a02bd7e6..90f866b50 100644 --- a/packages/ui/src/routes/[projectId]/components/LocalCommits.svelte +++ b/packages/ui/src/routes/[projectId]/components/LocalCommits.svelte @@ -17,6 +17,7 @@ import Tag from './Tag.svelte'; import { open } from '@tauri-apps/api/shell'; import toast from 'svelte-french-toast'; + import { sleep } from '$lib/utils/sleep'; export let branch: Branch; export let githubContext: GitHubIntegrationContext | undefined; @@ -64,7 +65,10 @@ async function push(opts?: { createPr: boolean }) { isPushing = true; await branchController.pushBranch(branch.id, branch.requiresForce); - if (opts?.createPr) await createPr(); + if (opts?.createPr) { + await sleep(500); + await createPr(); + } isPushing = false; }