Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/lib/components/git/connectRepoModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
let selectedRepository = $state('');
let installations = $state({ installations: [], total: 0 });
let error = $state('');
let isConnecting = $state(false);
onMount(async () => {
installations = await sdk
Expand All @@ -53,6 +54,9 @@
});
async function connectRepo() {
if (isConnecting) return;
isConnecting = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great approach for solving a lot of UX issues 💯

I would fully agree with his, if it was user clicking button twice, causing this.

Problem is, here it seems to be hapening automatically - you click once, but this function seems to be called twice. Internally, something is going on, causing this issue.

Let's please debug a bit further, to find the root cause. I think knowing that, we will find nicer solution at the source, instead of preventing the outcome with a patch

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, Sir! 🙏

You were right, the function was being called twice because connectRepo() was triggered both on repository selection and the modal’s onSubmit. I’ve removed the extra call so now it runs only once via onSubmit.

Updated the PR, please have a look when you get a chance.

try {
if (repositoryBehaviour === 'new') {
const repo = await sdk
Expand All @@ -74,6 +78,8 @@
});
} catch (e) {
error = e.message;
} finally {
isConnecting = false;
}
}
</script>
Expand Down Expand Up @@ -131,7 +137,10 @@
</Layout.Stack>
{:else if repositoryBehaviour === 'new'}
<Button text size="s" on:click={() => (show = false)}>Cancel</Button>
<Button size="s" submit disabled={!repositoryName || !$installation?.$id}>
<Button
size="s"
submit
disabled={!repositoryName || !$installation?.$id || isConnecting}>
Create
</Button>
{/if}
Expand Down