Skip to content

Commit

Permalink
Only leave form if API request succeeded
Browse files Browse the repository at this point in the history
If the "Ask to join" request failed for any reason, we don't want to
navigate away from the form.
  • Loading branch information
rmunn committed Aug 5, 2024
1 parent 66d11a4 commit 6539a7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 6 additions & 4 deletions frontend/src/routes/(authenticated)/project/create/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@
let showRelatedProjects = true;
async function askToJoinProject(projectId: string, projectName: string): Promise<void> {
await _askToJoinProject(projectId);
notifySuccess($t('project.create.join_request_sent', { projectName }))
$tainted = undefined; // Prevent "are you sure you want to leave?" warning
await goto('/');
const joinResult = await _askToJoinProject(projectId);
if (!joinResult.error) {
notifySuccess($t('project.create.join_request_sent', { projectName }))
$tainted = undefined; // Prevent "are you sure you want to leave?" warning
await goto('/');
}
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,4 @@ export async function _askToJoinProject(projectId: string): $OpResult<AskToJoinP
`),
{ input: { projectId } });
return result;
//
}

0 comments on commit 6539a7a

Please sign in to comment.