Skip to content

Commit

Permalink
[MS] Slight improvement of disconnect handling during the invitation …
Browse files Browse the repository at this point in the history
…process
  • Loading branch information
Max-7 committed Oct 31, 2024
1 parent 373f6c5 commit 756451e
Showing 5 changed files with 49 additions and 23 deletions.
6 changes: 6 additions & 0 deletions client/src/components/sas-code/SasCodeChoice.vue
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
<ion-button
class="button-choice code"
fill="outline"
:disabled="disabled"
@click="$emit('select', choices[0])"
>
{{ choices[0] }}
@@ -16,6 +17,7 @@
<ion-button
class="button-choice code"
fill="outline"
:disabled="disabled"
@click="$emit('select', choices[1])"
>
{{ choices[1] }}
@@ -27,6 +29,7 @@
<ion-button
class="button-choice code"
fill="outline"
:disabled="disabled"
@click="$emit('select', choices[2])"
>
{{ choices[2] }}
@@ -36,6 +39,7 @@
<ion-button
class="button-choice code"
fill="outline"
:disabled="disabled"
@click="$emit('select', choices[3])"
>
{{ choices[3] }}
@@ -47,6 +51,7 @@
<ion-button
class="button-clear"
fill="clear"
:disabled="disabled"
@click="$emit('select', null)"
>
{{ $msTranslate('SasCodeChoice.noneOfTheChoices') }}
@@ -61,6 +66,7 @@ import { IonButton, IonCol, IonGrid, IonRow } from '@ionic/vue';

defineProps<{
choices: string[];
disabled?: boolean;
}>();

defineEmits<{
2 changes: 2 additions & 0 deletions client/src/parsec/greet_user.ts
Original file line number Diff line number Diff line change
@@ -96,6 +96,7 @@ export class UserGreet {
}
return result;
} else {
await wait(MOCK_WAITING_TIME);
this.hostSASCode = '2EDF';
return {
ok: true,
@@ -158,6 +159,7 @@ export class UserGreet {
this.canceller = null;
return result;
} else {
await wait(MOCK_WAITING_TIME);
return { ok: true, value: { handle: DEFAULT_HANDLE } };
}
}
13 changes: 10 additions & 3 deletions client/src/views/home/UserJoinOrganizationModal.vue
Original file line number Diff line number Diff line change
@@ -85,6 +85,7 @@
class="step"
>
<sas-code-choice
:disabled="querying"
:choices="claimer.SASCodeChoices"
@select="selectHostSas($event)"
/>
@@ -152,10 +153,10 @@
</span>
</ion-button>
<div
v-show="waitingForHost"
v-show="waitingForHost || querying"
class="spinner-container"
>
<ms-spinner title="JoinOrganization.waitingForHost" />
<ms-spinner :title="!querying ? 'JoinOrganization.waitingForHost' : undefined" />
</div>
</ion-buttons>
</ion-footer>
@@ -213,6 +214,7 @@ const authChoice = ref();
const fieldsUpdated = ref(false);
const cancelled = ref(false);
const organizationName: Ref<OrganizationID> = ref('');
const querying = ref(false);

const claimer = ref(new UserClaim());

@@ -283,7 +285,10 @@ async function showErrorAndRestart(message: Translatable): Promise<void> {
async function selectHostSas(selectedCode: string | null): Promise<void> {
if (!selectedCode) {
await showErrorAndRestart('JoinOrganization.errors.noneCodeSelected');
} else {
return;
}
try {
querying.value = true;
if (selectedCode === claimer.value.correctSASCode) {
const result = await claimer.value.signifyTrust();
if (result.ok) {
@@ -306,6 +311,8 @@ async function selectHostSas(selectedCode: string | null): Promise<void> {
await claimer.value.denyTrust();
await showErrorAndRestart('JoinOrganization.errors.invalidCodeSelected');
}
} finally {
querying.value = false;
}
}

50 changes: 30 additions & 20 deletions client/src/views/users/GreetUserModal.vue
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@
class="step"
>
<sas-code-choice
:disabled="querying"
:choices="greeter.SASCodeChoices"
@select="selectGuestSas"
/>
@@ -140,10 +141,13 @@
</span>
</ion-button>
<div
v-show="waitingForGuest"
v-show="waitingForGuest || querying"
class="spinner-container"
>
<ion-text class="subtitles-normal">
<ion-text
class="subtitles-normal"
v-show="!querying"
>
{{ $msTranslate('UsersPage.greet.waiting') }}
</ion-text>
<ms-spinner class="spinner" />
@@ -199,6 +203,7 @@ const canGoForward = ref(false);
const waitingForGuest = ref(true);
const greeter = ref(new UserGreet());
const cancelled = ref(false);
const querying = ref(false);

const profileOptions: MsOptions = new MsOptions([
{
@@ -269,27 +274,32 @@ async function selectGuestSas(code: string | null): Promise<void> {
await showErrorAndRestart('UsersPage.greet.errors.noneCodeSelected');
return;
}
if (code === greeter.value.correctSASCode) {
const result = await greeter.value.signifyTrust();
if (result.ok) {
await nextStep();
} else {
if (result.error.tag === GreetInProgressErrorTag.GreetingAttemptCancelled) {
switch (result.error.reason) {
case CancelledGreetingAttemptReason.ManuallyCancelled:
await showErrorAndRestart('UsersPage.greet.errors.claimer.manuallyCancelled');
break;
default:
await showErrorAndRestart('UsersPage.greet.errors.claimer.default');
break;
}
try {
querying.value = true;
if (code === greeter.value.correctSASCode) {
const result = await greeter.value.signifyTrust();
if (result.ok) {
await nextStep();
} else {
await showErrorAndRestart({ key: 'UsersPage.greet.errors.unexpected', data: { reason: result.error.tag } });
if (result.error.tag === GreetInProgressErrorTag.GreetingAttemptCancelled) {
switch (result.error.reason) {
case CancelledGreetingAttemptReason.ManuallyCancelled:
await showErrorAndRestart('UsersPage.greet.errors.claimer.manuallyCancelled');
break;
default:
await showErrorAndRestart('UsersPage.greet.errors.claimer.default');
break;
}
} else {
await showErrorAndRestart({ key: 'UsersPage.greet.errors.unexpected', data: { reason: result.error.tag } });
}
}
} else {
await greeter.value.denyTrust();
await showErrorAndRestart('UsersPage.greet.errors.invalidCodeSelected');
}
} else {
await greeter.value.denyTrust();
await showErrorAndRestart('UsersPage.greet.errors.invalidCodeSelected');
} finally {
querying.value = false;
}
}

1 change: 1 addition & 0 deletions newsfragments/8817.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Slight improvement of how connection problems are handled during the greeting process

0 comments on commit 756451e

Please sign in to comment.