feat: add sleep function to delay PR creation after pushing branch

This commit is contained in:
Mattias Granlund 2023-11-28 20:41:06 +01:00
parent e0aea09ef1
commit e0d889dd85
2 changed files with 8 additions and 1 deletions

View File

@ -0,0 +1,3 @@
export function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

View File

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