Skip to content

Commit

Permalink
feat: disable the create group button when creating (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
howard9199 authored Dec 25, 2024
1 parent 5959c9a commit 07fa0da
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib/components/session/ParticipantView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
let pInitFFmpeg: Promise<void> | null = null;
let selfUser: Promise<Profile> | null = null;
let isCreatingGroup = $state(false);
onMount(() => {
const groupsRef = collection(db, 'sessions', $page.params.id, 'groups');
const groupDocQuery = query(groupsRef, where('participants', 'array-contains', user.uid));
Expand Down Expand Up @@ -119,6 +121,9 @@
});
async function handleCreateGroup() {
if (isCreatingGroup) return;
isCreatingGroup = true;
try {
const response = await fetch(`/api/session/${$page.params.id}/group`, {
method: 'POST'
Expand All @@ -135,6 +140,8 @@
} catch (error) {
console.error('Error creating group:', error);
notifications.error('Failed to create group');
} finally {
isCreatingGroup = false;
}
}
Expand Down Expand Up @@ -612,9 +619,9 @@
</Button>
</div>
{:else}
<Button color="primary" on:click={handleCreateGroup}>
<Button color="primary" on:click={handleCreateGroup} disabled={isCreatingGroup}>
<Users class="mr-2 h-4 w-4" />
Create New Group
{isCreatingGroup ? 'Creating...' : 'Create New Group'}
</Button>
{/if}
<Button color="alternative" on:click={() => (creating = !creating)}>
Expand Down

0 comments on commit 07fa0da

Please sign in to comment.