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; }