A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
feat(app): redeem account handoff links on arrival
Hampusb13d843e32da
diff --git a/fluxer_app/src/features/auth/components/AccountHandoffArrival.tsx b/fluxer_app/src/features/auth/components/AccountHandoffArrival.tsxnew file mode 100644index 000000000..4489c641a--- /dev/null+++ b/fluxer_app/src/features/auth/components/AccountHandoffArrival.tsx@@ -0,0 +1,49 @@+// SPDX-License-Identifier: AGPL-3.0-or-later++import {Routes} from '@app/app/Routes';+import {AuthLayout} from '@app/features/app/components/layout/AuthLayout';+import {AppSkeleton} from '@app/features/app/components/skeleton/AppSkeleton';+import type {AccountHandoffOutcome} from '@app/features/auth/flow/AccountHandoffRedeem';+import {createAuthRoutePage} from '@app/features/auth/flow/AuthLoadableRoutePage';+import {isAgeBlocked} from '@app/features/auth/state/AccountEntryStorage';+import {readCapturedAccountHandoff} from '@app/features/auth/state/AccountHandoffCapture';+import {loadLazyModule} from '@app/features/platform/utils/LazyModuleLoader';+import {isDesktop} from '@app/features/ui/utils/NativeUtils';+import {useEffect, useState} from 'react';++const StartPage = createAuthRoutePage('StartPage', () => import('@app/features/auth/components/pages/StartPage'));++const PENDING = 'pending';++type ArrivalState = Exclude<AccountHandoffOutcome, {readonly kind: 'signed_in'}> | null | typeof PENDING;++function redeemsOnArrival(): boolean {+ const handoff = readCapturedAccountHandoff();+ return handoff !== null && handoff.name !== '' && !isAgeBlocked() && !isDesktop();+}++export function AccountHandoffArrival() {+ const [arrival, setArrival] = useState<ArrivalState>(() => (redeemsOnArrival() ? PENDING : null));+ useEffect(() => {+ void StartPage.preload();+ if (arrival !== PENDING) return;+ let active = true;+ void loadLazyModule(() => import('@app/features/auth/flow/AccountHandoffRedeem'))+ .then(({redeemAccountHandoffOnArrival}) => redeemAccountHandoffOnArrival())+ .catch((error: unknown): AccountHandoffOutcome => ({kind: 'failed', error}))+ .then((outcome) => {+ if (active && outcome.kind !== 'signed_in') setArrival(outcome);+ });+ return () => {+ active = false;+ };+ }, [arrival]);+ if (arrival === PENDING) {+ return <AppSkeleton effectivePathname={Routes.ME} data-flx="auth.account-handoff-arrival.app-skeleton" />;+ }+ return (+ <AuthLayout data-flx="auth.account-handoff-arrival.auth-layout">+ <StartPage arrival={arrival} data-flx="auth.account-handoff-arrival.start-page" />+ </AuthLayout>+ );+}diff --git a/fluxer_app/src/features/auth/components/pages/StartPage.tsx b/fluxer_app/src/features/auth/components/pages/StartPage.tsxnew file mode 100644index 000000000..c104013f7--- /dev/null+++ b/fluxer_app/src/features/auth/components/pages/StartPage.tsx@@ -0,0 +1,268 @@+// SPDX-License-Identifier: AGPL-3.0-or-later++import {Routes} from '@app/app/Routes';+import type {RuntimeConfigSnapshot} from '@app/features/app/state/InstanceSnapshotStore';+import * as AuthenticationCommands from '@app/features/auth/commands/AuthenticationCommands';+import {AgeBlockedNotice} from '@app/features/auth/components/AgeBlockedNotice';+import loginStyles from '@app/features/auth/components/pages/LoginPage.module.css';+import {+ type AccountHandoffOutcome,+ accountLabel,+ finishAccountHandoffArrival,+ redeemCapturedAccountHandoff,+} from '@app/features/auth/flow/AccountHandoffRedeem';+import {AuthCardContainer} from '@app/features/auth/flow/AuthCardContainer';+import {AuthErrorState} from '@app/features/auth/flow/AuthErrorState';+import {AuthRouterLink} from '@app/features/auth/flow/AuthRouterLink';+import {AuthRuntimeTargetGate} from '@app/features/auth/flow/AuthRuntimeTargetGate';+import {+ InstantAccountForm,+ instantAccountErrors,+ NO_INSTANT_ACCOUNT_ERRORS,+} from '@app/features/auth/flow/InstantAccountForm';+import {+ CREATE_YOUR_ACCOUNT_DESCRIPTOR,+ SIGN_IN_TO_EXISTING_ACCOUNT_DESCRIPTOR,+} from '@app/features/auth/flow/identifier_first/AuthIdentifierFirstStep';+import styles from '@app/features/auth/flow/identifier_first/AuthIdentifierFirstStep.module.css';+import {getRegistrationLegalConsentConfig} from '@app/features/auth/flow/RegistrationLegalNotice';+import {useAuthPresentation} from '@app/features/auth/flow/useAuthPresentation';+import {getAuthErrorMessage} from '@app/features/auth/hooks/useAuthForm';+import {isAgeBlocked} from '@app/features/auth/state/AccountEntryStorage';+import {clearCapturedAccountHandoff, readCapturedAccountHandoff} from '@app/features/auth/state/AccountHandoffCapture';+import {AuthCardVariant} from '@app/features/auth/state/AuthLayoutContext';+import {openGuildWhenAvailable} from '@app/features/guild/commands/GuildVisitCommands';+import {isolateBidi} from '@app/features/i18n/utils/BidiIsolate';+import {CONTINUE_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';+import SessionManager from '@app/features/platform/state/AuthSession';+import {Logger} from '@app/features/platform/utils/AppLogger';+import {Button, ButtonVariant} from '@app/features/ui/button/Button';+import {isMobileExperienceEnabled} from '@app/features/ui/utils/MobileExperience';+import {useFluxerDocumentTitle} from '@app/features/window/hooks/useFluxerDocumentTitle';+import type {I18n} from '@lingui/core';+import {msg} from '@lingui/core/macro';+import {useLingui} from '@lingui/react/macro';+import {LinkBreakIcon} from '@phosphor-icons/react';+import {observer} from 'mobx-react-lite';+import {useMemo, useState} from 'react';++const logger = new Logger('StartPage');++const SETTING_UP_DESCRIPTOR = msg({+ message: 'Setting up your account',+ comment: 'Browser tab title while the app signs in to an account made on the website.',+});+const LINK_EXPIRED_TITLE_DESCRIPTOR = msg({+ message: 'This link has expired',+ comment: 'Heading when the link from the website that signs in a new account was already used or is too old.',+});+const LINK_EXPIRED_TEXT_DESCRIPTOR = msg({+ message: 'Sign in or create an account to continue.',+ comment: 'Text under the expired link heading.',+});+const NEW_ACCOUNT_READY_DESCRIPTOR = msg({+ message: 'Your new account is ready',+ comment: 'Heading when someone made a new account on the website while already signed in to another account.',+});+const NEW_ACCOUNT_CHOICE_DESCRIPTOR = msg({+ message: "You're signed in as {current}. Do you want to switch to {created}?",+ comment: 'Text under the new account heading. current and created are usernames.',+});+const SWITCH_TO_DESCRIPTOR = msg({+ message: 'Switch to {username}',+ comment: 'Button that switches to the account just made on the website. username is its name.',+});+const STAY_AS_DESCRIPTOR = msg({+ message: 'Stay as {username}',+ comment: 'Button that keeps the account already signed in. username is its name.',+});++type StartArrival = Exclude<AccountHandoffOutcome, {readonly kind: 'signed_in'}>;++type StartState =+ | {readonly kind: 'details'}+ | {readonly kind: 'expired'}+ | {readonly kind: 'failed'; readonly message: string}+ | {readonly kind: 'age_blocked'}+ | Extract<AccountHandoffOutcome, {readonly kind: 'choose'}>;++function startStateFor(outcome: StartArrival, i18n: I18n): StartState {+ switch (outcome.kind) {+ case 'retry':+ return {kind: 'details'};+ case 'failed':+ return {kind: 'failed', message: getAuthErrorMessage(outcome.error, i18n)};+ default:+ return outcome;+ }+}++const StartPageContent = observer(function StartPageContent({+ runtimeSnapshot,+ arrival,+}: {+ readonly runtimeSnapshot: RuntimeConfigSnapshot;+ readonly arrival: StartArrival | null;+}) {+ const {i18n} = useLingui();+ const consentConfig = useMemo(() => getRegistrationLegalConsentConfig(runtimeSnapshot), [runtimeSnapshot]);+ const [initialName] = useState(() => readCapturedAccountHandoff()?.name ?? '');+ const [state, setState] = useState<StartState>(() => {+ if (arrival !== null) return startStateFor(arrival, i18n);+ if (readCapturedAccountHandoff() === null) return {kind: 'expired'};+ if (isAgeBlocked()) {+ clearCapturedAccountHandoff();+ return {kind: 'age_blocked'};+ }+ return {kind: 'details'};+ });+ const [submitting, setSubmitting] = useState(false);+ const [errors, setErrors] = useState(() =>+ arrival?.kind === 'retry' ? instantAccountErrors(arrival.error, i18n) : NO_INSTANT_ACCOUNT_ERRORS,+ );+ const [switching, setSwitching] = useState(false);++ const redeem = async (globalName: string) => {+ setSubmitting(true);+ setErrors(NO_INSTANT_ACCOUNT_ERRORS);+ const outcome = await redeemCapturedAccountHandoff(globalName, runtimeSnapshot);+ setSubmitting(false);+ if (outcome.kind === 'signed_in') return;+ if (outcome.kind === 'retry') {+ setErrors(instantAccountErrors(outcome.error, i18n));+ return;+ }+ setState(startStateFor(outcome, i18n));+ };++ if (state.kind === 'age_blocked') {+ return (+ <>+ <AgeBlockedNotice data-flx="auth.start-page.age-blocked" />+ <div className={styles.quietActions} data-flx="auth.start-page.age-blocked-actions">+ <AuthRouterLink+ to={Routes.LOGIN}+ className={styles.textButton}+ data-flx="auth.start-page.link.sign-in-existing"+ >+ {i18n._(SIGN_IN_TO_EXISTING_ACCOUNT_DESCRIPTOR)}+ </AuthRouterLink>+ </div>+ </>+ );+ }+ if (state.kind === 'expired' || state.kind === 'failed') {+ return (+ <AuthErrorState+ icon={LinkBreakIcon}+ title={state.kind === 'failed' ? state.message : i18n._(LINK_EXPIRED_TITLE_DESCRIPTOR)}+ text={i18n._(LINK_EXPIRED_TEXT_DESCRIPTOR)}+ action={+ <AuthRouterLink to={Routes.LOGIN} className={styles.textButton} data-flx="auth.start-page.link.login">+ {i18n._(CONTINUE_DESCRIPTOR)}+ </AuthRouterLink>+ }+ data-flx="auth.start-page.expired"+ />+ );+ }+ if (state.kind === 'details') {+ const details = (+ <flx-auth-start-page className="flx-element" data-flx="auth.start-page.details">+ <h1 className={loginStyles.title} dir="auto" data-flx="auth.start-page.details-title">+ {i18n._(CREATE_YOUR_ACCOUNT_DESCRIPTOR)}+ </h1>+ <InstantAccountForm+ initialName={initialName}+ consentConfig={consentConfig}+ submitting={submitting}+ errors={errors}+ onEdit={() => setErrors(NO_INSTANT_ACCOUNT_ERRORS)}+ onSubmit={(globalName) => void redeem(globalName)}+ data-flx="auth.start-page.details-form"+ />+ </flx-auth-start-page>+ );+ if (!isMobileExperienceEnabled()) return details;+ return (+ <AuthCardContainer variant={AuthCardVariant.COMPACT} data-flx="auth.start-page.details-mobile-card">+ {details}+ </AuthCardContainer>+ );+ }+ const created = accountLabel(state.payload.userData, state.payload.userId);+ const handleSwitch = async () => {+ setSwitching(true);+ try {+ await AuthenticationCommands.completeLogin({...state.payload, runtimeSnapshot}, {redirectPath: Routes.ME});+ finishAccountHandoffArrival();+ if (state.entry !== null) void openGuildWhenAvailable(state.entry.guild_id);+ } catch (error) {+ logger.warn('Switching to the new account failed', error);+ setState({kind: 'failed', message: getAuthErrorMessage(error, i18n)});+ } finally {+ setSwitching(false);+ }+ };+ const handleStay = async () => {+ setSwitching(true);+ try {+ await SessionManager.addStoredAccount({+ userId: state.payload.userId,+ token: state.payload.token,+ userData: state.payload.userData,+ instance: runtimeSnapshot,+ });+ } catch (error) {+ logger.warn('Keeping the new account in the account switcher failed', error);+ } finally {+ setSwitching(false);+ }+ finishAccountHandoffArrival();+ };+ const choice = (+ <flx-auth-start-page className="flx-element" data-flx="auth.start-page.choose">+ <h1 className={loginStyles.title} dir="auto" data-flx="auth.start-page.title">+ {i18n._(NEW_ACCOUNT_READY_DESCRIPTOR)}+ </h1>+ <p className={styles.description} dir="auto" data-flx="auth.start-page.description">+ {i18n._(NEW_ACCOUNT_CHOICE_DESCRIPTOR, {current: isolateBidi(state.current), created: isolateBidi(created)})}+ </p>+ <div className={styles.form} data-flx="auth.start-page.actions">+ <Button fitContainer submitting={switching} onClick={handleSwitch} data-flx="auth.start-page.button.switch">+ {i18n._(SWITCH_TO_DESCRIPTOR, {username: isolateBidi(created)})}+ </Button>+ <Button+ fitContainer+ variant={ButtonVariant.SECONDARY}+ disabled={switching}+ onClick={() => void handleStay()}+ data-flx="auth.start-page.button.stay"+ >+ {i18n._(STAY_AS_DESCRIPTOR, {username: isolateBidi(state.current)})}+ </Button>+ </div>+ </flx-auth-start-page>+ );+ if (!isMobileExperienceEnabled()) return choice;+ return (+ <AuthCardContainer variant={AuthCardVariant.COMPACT} data-flx="auth.start-page.mobile-card">+ {choice}+ </AuthCardContainer>+ );+});++const StartPage = observer(function StartPage({arrival}: {readonly arrival: StartArrival | null}) {+ const {i18n} = useLingui();+ useFluxerDocumentTitle(i18n._(SETTING_UP_DESCRIPTOR));+ useAuthPresentation({variant: AuthCardVariant.COMPACT});+ return (+ <AuthRuntimeTargetGate data-flx="auth.start-page.runtime-target-gate">+ {(runtimeSnapshot) => (+ <StartPageContent runtimeSnapshot={runtimeSnapshot} arrival={arrival} data-flx="auth.start-page.content" />+ )}+ </AuthRuntimeTargetGate>+ );+});++export default StartPage;diff --git a/fluxer_app/src/features/auth/flow/AccountHandoffRedeem.ts b/fluxer_app/src/features/auth/flow/AccountHandoffRedeem.tsnew file mode 100644index 000000000..21c39e0a4--- /dev/null+++ b/fluxer_app/src/features/auth/flow/AccountHandoffRedeem.ts@@ -0,0 +1,121 @@+// SPDX-License-Identifier: AGPL-3.0-or-later++import {Routes} from '@app/app/Routes';+import type {RuntimeConfigSnapshot} from '@app/features/app/state/InstanceSnapshotStore';+import {redeemAccountHandoff} from '@app/features/auth/commands/AccountEntryCommands';+import * as AuthenticationCommands from '@app/features/auth/commands/AuthenticationCommands';+import {readyBrowserAuthRuntime} from '@app/features/auth/flow/AuthRuntimeTargetBoundary';+import {+ clearCapturedAccountHandoff,+ endAccountHandoffArrival,+ isAccountHandoffArrival,+ readCapturedAccountHandoff,+} from '@app/features/auth/state/AccountHandoffCapture';+import type {UserData} from '@app/features/auth/state/AccountStorageContract';+import Accounts from '@app/features/auth/state/Accounts';+import type {LoginSuccessPayload} from '@app/features/auth/state/AuthFlow';+import {openGuildWhenAvailable} from '@app/features/guild/commands/GuildVisitCommands';+import {getDefaultLandingPath} from '@app/features/navigation/utils/DefaultLandingUtils';+import * as RouterUtils from '@app/features/navigation/utils/RouterUtils';+import {Logger} from '@app/features/platform/utils/AppLogger';+import {failureCode, failureValidationErrors} from '@app/features/platform/utils/ResponseInspection';+import {formatUserTag} from '@app/features/user/utils/UserTagUtils';+import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes';+import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes';+import type {GuildEntryResult} from '@fluxer/schema/src/domains/user/AccountSchemas';++const logger = new Logger('AccountHandoffRedeem');++const RUNTIME_TIMEOUT_MS = 10_000;++const TERMINAL_HANDOFF_CODES = new Set<string>([+ APIErrorCodes.UNKNOWN_ACCOUNT_HANDOFF,+ APIErrorCodes.INVALID_ACCOUNT_HANDOFF_NONCE,+]);++export type AccountHandoffOutcome =+ | {readonly kind: 'signed_in'}+ | {readonly kind: 'retry'; readonly error: unknown}+ | {readonly kind: 'expired'}+ | {readonly kind: 'failed'; readonly error: unknown}+ | {+ readonly kind: 'choose';+ readonly payload: LoginSuccessPayload;+ readonly entry: GuildEntryResult | null;+ readonly current: string;+ };++export function accountLabel(user: UserData | undefined, fallback: string): string {+ return user == null || user.username === '' ? fallback : formatUserTag(user);+}++function isRetryable(error: unknown): boolean {+ if (failureCode(error) === APIErrorCodes.CONTENT_BLOCKED) return true;+ return (+ failureValidationErrors(error)?.some(+ (fault) =>+ fault.path === 'global_name' ||+ (fault.path === 'consent' && fault.code === ValidationErrorCodes.MUST_AGREE_TO_TOS_AND_PRIVACY_POLICY),+ ) === true+ );+}++export function finishAccountHandoffArrival(): void {+ const arrived = isAccountHandoffArrival(window.location.pathname);+ endAccountHandoffArrival();+ if (arrived) RouterUtils.replaceWith(getDefaultLandingPath());+}++export async function redeemCapturedAccountHandoff(+ globalName: string,+ snapshot: RuntimeConfigSnapshot,+): Promise<AccountHandoffOutcome> {+ const handoff = readCapturedAccountHandoff();+ if (handoff === null) return {kind: 'expired'};+ try {+ const {payload, entry} = await redeemAccountHandoff({+ handoffCode: handoff.handoffCode,+ nonce: handoff.nonce,+ consent: true,+ globalName,+ snapshot,+ });+ clearCapturedAccountHandoff();+ const current = Accounts.currentAccount;+ if (current !== null) {+ return {kind: 'choose', payload, entry, current: accountLabel(current.userData, current.userId)};+ }+ await AuthenticationCommands.completeLogin({...payload, runtimeSnapshot: snapshot}, {redirectPath: Routes.ME});+ finishAccountHandoffArrival();+ if (entry !== null) void openGuildWhenAvailable(entry.guild_id);+ return {kind: 'signed_in'};+ } catch (error) {+ if (isRetryable(error)) return {kind: 'retry', error};+ clearCapturedAccountHandoff();+ const code = failureCode(error);+ if (code !== undefined && TERMINAL_HANDOFF_CODES.has(code)) {+ logger.warn('Account handoff could not be redeemed', error);+ return {kind: 'expired'};+ }+ return {kind: 'failed', error};+ }+}++async function redeemOnArrival(): Promise<AccountHandoffOutcome> {+ const name = readCapturedAccountHandoff()?.name ?? '';+ let snapshot: RuntimeConfigSnapshot;+ try {+ snapshot = await readyBrowserAuthRuntime(AbortSignal.timeout(RUNTIME_TIMEOUT_MS));+ } catch (error) {+ logger.warn('The instance for the account handoff could not be resolved', error);+ return {kind: 'failed', error};+ }+ return redeemCapturedAccountHandoff(name, snapshot);+}++let arrival: Promise<AccountHandoffOutcome> | null = null;++export function redeemAccountHandoffOnArrival(): Promise<AccountHandoffOutcome> {+ arrival ??= redeemOnArrival();+ return arrival;+}diff --git a/fluxer_app/src/features/auth/state/AccountHandoffCapture.ts b/fluxer_app/src/features/auth/state/AccountHandoffCapture.tsnew file mode 100644index 000000000..512473025--- /dev/null+++ b/fluxer_app/src/features/auth/state/AccountHandoffCapture.ts@@ -0,0 +1,104 @@+// SPDX-License-Identifier: AGPL-3.0-or-later++import {getProtectedSessionStorage} from '@app/features/platform/state/ProtectedWebStorage';+import {Logger} from '@app/features/platform/utils/AppLogger';+import {action, observable} from 'mobx';++const logger = new Logger('AccountHandoffCapture');++const ARRIVAL_PATH = '/channels/@me';+const LEGACY_HANDOFF_PATH = '/channels/@start';+const APP_ENTRY_PATHS: ReadonlySet<string> = new Set(['/', '/app', ARRIVAL_PATH]);++interface CapturedAccountHandoff {+ readonly handoffCode: string;+ readonly nonce: string;+ readonly name: string;+}++const HANDOFF_CODE_PATTERN = /^[A-Za-z0-9_-]{43}$/;+const NONCE_PATTERN = /^[A-Za-z0-9_-]{16,256}$/;+const MAX_NAME_LENGTH = 256;++const HANDOFF_STORAGE_KEY = 'fluxer.account_handoff';++let captured: CapturedAccountHandoff | null = null;+const arrival = observable.box(false);++function storeHandoff(handoff: CapturedAccountHandoff | null): void {+ try {+ const storage = getProtectedSessionStorage();+ if (handoff === null) {+ storage?.removeItem(HANDOFF_STORAGE_KEY);+ } else {+ const params = new URLSearchParams({handoff: handoff.handoffCode, nonce: handoff.nonce, name: handoff.name});+ storage?.setItem(HANDOFF_STORAGE_KEY, `#${params.toString()}`);+ }+ } catch (error) {+ logger.warn('Failed to update stored account handoff', error);+ }+}++function readStoredHandoff(): CapturedAccountHandoff | null {+ try {+ return parseAccountHandoffFragment(getProtectedSessionStorage()?.getItem(HANDOFF_STORAGE_KEY) ?? '');+ } catch (error) {+ logger.warn('Failed to read stored account handoff', error);+ return null;+ }+}++function parseAccountHandoffFragment(hash: string): CapturedAccountHandoff | null {+ const params = new URLSearchParams(hash.startsWith('#') ? hash.slice(1) : hash);+ const handoffCode = params.get('handoff') ?? '';+ const nonce = params.get('nonce') ?? '';+ if (!HANDOFF_CODE_PATTERN.test(handoffCode) || !NONCE_PATTERN.test(nonce)) {+ return null;+ }+ return {handoffCode, nonce, name: (params.get('name') ?? '').trim().slice(0, MAX_NAME_LENGTH)};+}++function resolveAccountHandoffLanding(location: {+ readonly pathname: string;+ readonly search: string;+ readonly hash: string;+}): {readonly handoff: CapturedAccountHandoff | null; readonly url: string} | null {+ const url = `${ARRIVAL_PATH}${location.search}`;+ if (location.pathname === LEGACY_HANDOFF_PATH) {+ return {handoff: parseAccountHandoffFragment(location.hash), url};+ }+ if (location.hash === '' || !APP_ENTRY_PATHS.has(location.pathname)) return null;+ const handoff = parseAccountHandoffFragment(location.hash);+ return handoff === null ? null : {handoff, url};+}++export const captureAccountHandoffFromLocation = action((): void => {+ const landing = resolveAccountHandoffLanding(window.location);+ if (landing !== null) {+ if (landing.handoff !== null) {+ captured = landing.handoff;+ storeHandoff(captured);+ }+ window.history.replaceState(window.history.state, '', landing.url);+ }+ arrival.set(window.location.pathname === ARRIVAL_PATH && readCapturedAccountHandoff() !== null);+});++export function isAccountHandoffArrival(pathname: string): boolean {+ return pathname === ARRIVAL_PATH && arrival.get();+}++export function readCapturedAccountHandoff(): CapturedAccountHandoff | null {+ captured = captured ?? readStoredHandoff();+ return captured;+}++export function clearCapturedAccountHandoff(): void {+ captured = null;+ storeHandoff(null);+}++export const endAccountHandoffArrival = action((): void => {+ clearCapturedAccountHandoff();+ arrival.set(false);+});