Send files directly between devices over the internet - no cloud storage, no size limits.
TypeScript cross-platformdata-transferdecentralizedfile-sharingfile-transferhole-punchingopen-sourcep2ppeer-to-peerprivacyprivacy-tools
add haptic feedback across the transfer flow
Denis Lupookov7048dc3f5035
diff --git a/apps/mobile/app/(tabs)/receive/index.tsx b/apps/mobile/app/(tabs)/receive/index.tsxindex bcba9e7..e057b8c 100644--- a/apps/mobile/app/(tabs)/receive/index.tsx+++ b/apps/mobile/app/(tabs)/receive/index.tsx@@ -1,5 +1,4 @@import React, { useCallback, useEffect, useMemo, useState } from 'react'-import * as Haptics from 'expo-haptics'import { Button } from '@altersend/components'import { useTranslation } from '@altersend/locales'import { useFocusEffect, useRouter } from 'expo-router'@@ -19,6 +18,7 @@ import {openCompletedFile} from '@/src/transfer/receive'import { useErrorToast } from '@/src/transfer/receive/utils/useErrorToast'+import { errorTap, mediumTap } from '@/src/haptics'import { Layout } from '@/src/components'export default function ReceiveScreen() {@@ -55,7 +55,7 @@ export default function ReceiveScreen() {setShowValidation(true)if (!isValidJoinCode) {if (trimmedJoinCode.length > 0) {- Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error).catch(() => {})+ errorTap()}return}@@ -99,10 +99,15 @@ export default function ReceiveScreen() {const copy = getReceivePageCopy(t, step, downloadableFileCount, textCount, totals.totalBytes)const title = step === 'join' ? t('receive:page.tabTitle') : copy.title+ const handleEndSession = () => {+ if (step !== 'interrupted') mediumTap()+ clearSession()+ }+const footer =step === 'join' ? undefined : (<Button- onClick={clearSession}+ onClick={handleEndSession}size='lg'variant={step === 'interrupted' ? 'primary' : 'secondary'}width='full'diff --git a/apps/mobile/app/receive/complete.tsx b/apps/mobile/app/receive/complete.tsxindex fea01bb..329d0e1 100644--- a/apps/mobile/app/receive/complete.tsx+++ b/apps/mobile/app/receive/complete.tsx@@ -4,6 +4,7 @@ import { useTranslation } from '@altersend/locales'import { useRouter } from 'expo-router'import { clearSession } from '@altersend/domain'import { mobileApi } from '@/src/api/mobileApi'+import { successTap } from '@/src/haptics'import { Layout } from '@/src/components'import { ReceiveCompleteView } from '@/src/transfer/receive'import { exitToReceiveTab } from '@/src/transfer/receive/utils/exitToReceiveTab'@@ -12,6 +13,7 @@ export default function ReceiveCompleteScreen() {const router = useRouter()useEffect(() => {+ successTap()void mobileApi.worker.closePeers().catch((err) => {console.warn('ReceiveCompleteScreen: closePeers failed', err)})diff --git a/apps/mobile/app/receive/incoming.tsx b/apps/mobile/app/receive/incoming.tsxindex ae4f2e7..1a4dfbf 100644--- a/apps/mobile/app/receive/incoming.tsx+++ b/apps/mobile/app/receive/incoming.tsx@@ -7,6 +7,7 @@ import { useTranslation } from '@altersend/locales'import { useRouter } from 'expo-router'import { uriToPath } from '@/src/api/mobileApi'import { ConfirmDialog, Layout, IllustrationLayout } from '@/src/components'+import { lightTap, mediumTap } from '@/src/haptics'import { useLeaveSessionConfirm } from '@/src/hooks/useLeaveSessionConfirm'import { ReceiveIncomingView, ReceiveReconnectingView } from '@/src/transfer/receive'import { useErrorToast } from '@/src/transfer/receive/utils/useErrorToast'@@ -57,10 +58,14 @@ export default function ReceiveIncomingScreen() {}}, [step, router])- const handleEndSession = useCallback(() => {+ const handleExit = useCallback(() => {void clearSession()exitToReceiveTab(router)}, [router])+ const handleEndSession = useCallback(() => {+ mediumTap()+ handleExit()+ }, [handleExit])const { leaveDialog } = useLeaveSessionConfirm(handleEndSession)const totalBytes = totals.totalBytes@@ -75,8 +80,11 @@ export default function ReceiveIncomingScreen() {const handlePrimaryAction = async () => {try {- if (downloads.primaryAction === 'resume-all') await actions.resumeAll()- else if (downloads.primaryAction === 'download-all') {+ if (downloads.primaryAction === 'resume-all') {+ lightTap()+ await actions.resumeAll()+ } else if (downloads.primaryAction === 'download-all') {+ lightTap()await actions.downloadInto(uriToPath(Paths.document.uri))}} catch (err) {@@ -143,7 +151,7 @@ export default function ReceiveIncomingScreen() {illustration={<ConnectionLostSvg width='100%' height='100%' />}aspectRatio={800 / 430}footer={- <Button onClick={handleEndSession} size='lg' variant='primary' width='full'>+ <Button onClick={handleExit} size='lg' variant='primary' width='full'>{t('receive:actions.backToHome')}</Button>}diff --git a/apps/mobile/app/send/share.tsx b/apps/mobile/app/send/share.tsxindex 07741af..e3d7cf2 100644--- a/apps/mobile/app/send/share.tsx+++ b/apps/mobile/app/send/share.tsx@@ -4,6 +4,7 @@ import { Button } from '@altersend/components'import { clearSenderFlow, getSendPageCopy, getSendStep, useTransferStore } from '@altersend/domain'import { useTranslation } from '@altersend/locales'import { ConfirmDialog, Layout } from '@/src/components'+import { mediumTap } from '@/src/haptics'import { useLeaveSessionConfirm } from '@/src/hooks/useLeaveSessionConfirm'import { ShareView } from '@/src/transfer/send'@@ -21,10 +22,11 @@ export default function SendShareScreen() {const copy = getSendPageCopy(t, step)const needsStayHint = step === 'receiver_connected' && !sustainsBackgroundTransfer- const handleBack = useCallback(() => {+ const handleEndSession = useCallback(() => {+ mediumTap()clearSenderFlow()}, [])- const { leaveDialog } = useLeaveSessionConfirm(handleBack)+ const { leaveDialog } = useLeaveSessionConfirm(handleEndSession)return (<Layout@@ -34,7 +36,7 @@ export default function SendShareScreen() {noScrollfooter={<View style={{ marginBottom: Platform.OS === 'android' ? 20 : 0 }}>- <Button onClick={clearSenderFlow} size='lg' variant='secondary' width='full'>+ <Button onClick={handleEndSession} size='lg' variant='secondary' width='full'>{t('common:actions.endSession')}</Button></View>diff --git a/apps/mobile/app/subscription.tsx b/apps/mobile/app/subscription.tsxindex 282e38e..1d89dbd 100644--- a/apps/mobile/app/subscription.tsx+++ b/apps/mobile/app/subscription.tsx@@ -8,7 +8,7 @@ import { useRouter } from 'expo-router'import { ConfirmDialog, Layout } from '@/src/components'import { useToast } from '@/src/components/Toast'import { useAccountModel } from '@/src/account'-import { selectionTap } from '@/src/account/haptics'+import { selectionTap } from '@/src/haptics'import { useCopyAccountCode } from '@/src/account/useCopyAccountCode'export default function SubscriptionScreen() {diff --git a/apps/mobile/src/account/CodeEntry.tsx b/apps/mobile/src/account/CodeEntry.tsxindex 4671624..e5434f0 100644--- a/apps/mobile/src/account/CodeEntry.tsx+++ b/apps/mobile/src/account/CodeEntry.tsx@@ -8,7 +8,7 @@ import { HeroBackdrop, Layout } from '@/src/components'import { IconButton } from '@/src/components/IconButton'import { Text } from '@/src/components/ThemedText'import { HEADER_TOP } from './constants'-import { selectionTap, successTap } from './haptics'+import { selectionTap, successTap } from '@/src/haptics'import type { AccountPhaseProps } from './types'export function CodeEntry({ model, errorText, onDismiss }: AccountPhaseProps) {diff --git a/apps/mobile/src/account/Paywall.tsx b/apps/mobile/src/account/Paywall.tsxindex 6258613..376bc83 100644--- a/apps/mobile/src/account/Paywall.tsx+++ b/apps/mobile/src/account/Paywall.tsx@@ -14,7 +14,7 @@ import { Text } from '@/src/components/ThemedText'import { purchasesReady } from '@/src/lifecycle/purchases'import { HEADER_TOP, SCREEN_PADDING } from './constants'import { PlanCellValue } from './PlanCellValue'-import { successTap } from './haptics'+import { successTap } from '@/src/haptics'import type { AccountPhaseProps } from './types'const PRO_COLUMN_WIDTH = 80diff --git a/apps/mobile/src/account/PurchaseSuccess.tsx b/apps/mobile/src/account/PurchaseSuccess.tsxindex 15a02a9..e009ce1 100644--- a/apps/mobile/src/account/PurchaseSuccess.tsx+++ b/apps/mobile/src/account/PurchaseSuccess.tsx@@ -6,7 +6,7 @@ import { useTranslation } from '@altersend/locales'import { ConfirmDialog, Layout } from '@/src/components'import { Text } from '@/src/components/ThemedText'import { DismissRow } from './DismissRow'-import { successTap } from './haptics'+import { successTap } from '@/src/haptics'import { useCopyAccountCode } from './useCopyAccountCode'import type { AccountPhaseProps } from './types'diff --git a/apps/mobile/src/account/haptics.ts b/apps/mobile/src/account/haptics.tsdeleted file mode 100644index 61a8d6f..0000000--- a/apps/mobile/src/account/haptics.ts+++ /dev/null@@ -1,15 +0,0 @@-import * as Haptics from 'expo-haptics'--const warn = (err: unknown) => console.warn('[account] haptic failed', err)--export function selectionTap(): void {- Haptics.selectionAsync().catch(warn)-}--export function impactTap(): Promise<void> {- return Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light)-}--export function successTap(): void {- Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success).catch(warn)-}diff --git a/apps/mobile/src/account/useCopyAccountCode.ts b/apps/mobile/src/account/useCopyAccountCode.tsindex a399c4c..788e804 100644--- a/apps/mobile/src/account/useCopyAccountCode.ts+++ b/apps/mobile/src/account/useCopyAccountCode.ts@@ -1,6 +1,6 @@import * as Clipboard from 'expo-clipboard'import { formatAccountCode, useCopiedFlag } from '@altersend/domain'-import { impactTap } from './haptics'+import { lightTap } from '@/src/haptics'const COPY_ID = 'account-code'@@ -19,7 +19,7 @@ export function useCopyAccountCode(code: string | undefined, onCopied?: () => voflashCopied(COPY_ID)onCopied?.()- await impactTap()+ lightTap()return true}diff --git a/apps/mobile/src/components/PairRequestBanner/index.tsx b/apps/mobile/src/components/PairRequestBanner/index.tsxindex 05da183..41d3c5d 100644--- a/apps/mobile/src/components/PairRequestBanner/index.tsx+++ b/apps/mobile/src/components/PairRequestBanner/index.tsx@@ -4,6 +4,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'import { Button, useTheme } from '@altersend/components'import { CheckIcon, CloseIcon, deviceIcon } from '@altersend/components/icons'import { rememberVote, usePairingSessionStore, useTransferStore } from '@altersend/domain'+import { lightTap } from '@/src/haptics'import { Text } from '@/src/components/ThemedText'export function PairRequestBanner() {@@ -24,6 +25,10 @@ export function PairRequestBanner() {const visible = Boolean(request && !responded && !isPairing)+ useEffect(() => {+ if (visible) lightTap()+ }, [visible])+// Guarded against double-firing: onDismiss (iOS swipe) also fires after a programmatic// close, so without the ref a tap on Pair would be followed by a stray 'no' vote.const respond = (vote: 'remember' | 'no') => {diff --git a/apps/mobile/src/haptics.ts b/apps/mobile/src/haptics.tsnew file mode 100644index 0000000..2320c96--- /dev/null+++ b/apps/mobile/src/haptics.ts@@ -0,0 +1,23 @@+import * as Haptics from 'expo-haptics'++const warn = (err: unknown) => console.warn('[haptics] failed', err)++export function selectionTap(): void {+ Haptics.selectionAsync().catch(warn)+}++export function lightTap(): void {+ Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light).catch(warn)+}++export function mediumTap(): void {+ Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium).catch(warn)+}++export function successTap(): void {+ Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success).catch(warn)+}++export function errorTap(): void {+ Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error).catch(warn)+}diff --git a/apps/mobile/src/transfer/receive/views/ReceiveIncomingView.tsx b/apps/mobile/src/transfer/receive/views/ReceiveIncomingView.tsxindex 45484ba..7499b50 100644--- a/apps/mobile/src/transfer/receive/views/ReceiveIncomingView.tsx+++ b/apps/mobile/src/transfer/receive/views/ReceiveIncomingView.tsx@@ -10,9 +10,17 @@ import {useReceiveDownloads} from '@altersend/domain'import { useTranslation } from '@altersend/locales'+import { lightTap } from '@/src/haptics'import { openCompletedFile } from '../utils/openCompletedFile'import { Text } from '@/src/components/ThemedText'+function withTap<Args extends unknown[]>(action: (...args: Args) => void) {+ return (...args: Args) => {+ lightTap()+ action(...args)+ }+}+export function ReceiveIncomingView() {const { t } = useTranslation(['receive', 'common', 'errors'])const { theme } = useTheme()@@ -24,6 +32,7 @@ export function ReceiveIncomingView() {const copyText = (id: string, content: string) => {void Clipboard.setStringAsync(content)flashCopied(id)+ lightTap()}if (!downloads.hasFiles && downloads.textOffers.length === 0) {@@ -50,11 +59,11 @@ export function ReceiveIncomingView() {labelsFor={(display) => getDownloadRowLabels(t, display)}transferActive={downloads.isDownloading}isFirst={index === 0}- onResume={actions.resumeFile}- onPause={actions.pauseFile}+ onResume={withTap(actions.resumeFile)}+ onPause={withTap(actions.pauseFile)}onOpen={(offer) => openCompletedFile(getOfferKey(offer))}- onPauseFolder={actions.pauseFolder}- onResumeFolder={actions.resumeFolder}+ onPauseFolder={withTap(actions.pauseFolder)}+ onResumeFolder={withTap(actions.resumeFolder)}/>))}</RowGroup>diff --git a/apps/mobile/src/transfer/receive/views/ReceiveInterruptedView.tsx b/apps/mobile/src/transfer/receive/views/ReceiveInterruptedView.tsxindex 7786bbf..b06c6fe 100644--- a/apps/mobile/src/transfer/receive/views/ReceiveInterruptedView.tsx+++ b/apps/mobile/src/transfer/receive/views/ReceiveInterruptedView.tsx@@ -1,4 +1,4 @@-import React, { PropsWithChildren } from 'react'+import React, { PropsWithChildren, useEffect } from 'react'import { StyleSheet, View } from 'react-native'import type { IncomingFileOffer } from '@altersend/core'import { LinkRow, useTheme, withAlpha } from '@altersend/components'@@ -6,6 +6,7 @@ import { CloseIcon } from '@altersend/components/icons'import { getOfferKey, type DownloadItemState } from '@altersend/domain'import { useTranslation } from '@altersend/locales'import { IllustrationLayout } from '@/src/components'+import { errorTap } from '@/src/haptics'import { OpenAction, getFileMeta } from '../utils/fileRowUtils'import MissingFilesSvg from '../../../../../../assets/missing-files.svg'import { Text } from '@/src/components/ThemedText'@@ -33,6 +34,10 @@ export function ReceiveInterruptedView({const { t } = useTranslation(['receive', 'common'])const { theme } = useTheme()+ useEffect(() => {+ errorTap()+ }, [])+const completedCount = incomingFileOffers.filter((file) => downloadStates[getOfferKey(file)]?.status === 'completed').lengthdiff --git a/apps/mobile/src/transfer/send/views/ShareView.tsx b/apps/mobile/src/transfer/send/views/ShareView.tsxindex 2ed73f7..dccbb54 100644--- a/apps/mobile/src/transfer/send/views/ShareView.tsx+++ b/apps/mobile/src/transfer/send/views/ShareView.tsx@@ -26,6 +26,7 @@ import {import { useTranslation } from '@altersend/locales'import { useRouter } from 'expo-router'import { useToast } from '@/src/components/Toast'+import { mediumTap, successTap } from '@/src/haptics'import { ConfirmDialog, DeviceActionsSheet, DeviceRenameSheet } from '@/src/components'import { useDeviceRename } from '@/src/pairing/useDeviceRename'import { useDeviceRemove } from '@/src/pairing/useDeviceRemove'@@ -52,6 +53,7 @@ export function ShareView() {}),onPeerPaired: (peer) =>toast.show({ title: t('send:status.pairedToast', { name: peer.name }), durationMs: 2500 }),+ onPeerDownloaded: successTap,onInviteFailed: (peer) =>toast.show({title: t('send:status.inviteFailedToast', { name: peer.name }),@@ -255,8 +257,10 @@ export function ShareView() {<LinkCard>{vm.devices.map((row, index) => {const isLast = index === vm.devices.length - 1- const openActions = () =>+ const openActions = () => {+ mediumTap()setActionsTarget({ peerKey: row.peerKey, name: row.name })+ }if (row.kind === 'connected') {const Icon = row.deviceType ? deviceIcon(row.deviceType) : nullreturn (diff --git a/packages/domain/src/send/useShareViewModel.ts b/packages/domain/src/send/useShareViewModel.tsindex 57f44a3..1cd21e3 100644--- a/packages/domain/src/send/useShareViewModel.ts+++ b/packages/domain/src/send/useShareViewModel.ts@@ -17,7 +17,7 @@ import {} from '../transfer/commands'import { useTransferStore } from '../transfer/store'import { applyPairState, getActivePeerProgress, getPeerListEntries } from './peerListUi'-import type { PairState, PeerListEntryWithPair } from './peerListUi'+import type { PairState, PeerListEntry, PeerListEntryWithPair } from './peerListUi'import type { Translate } from '../i18n'import { useCopiedFlag } from '../useCopiedFlag'@@ -198,6 +198,7 @@ function toInviteAction(st: InviteStatus | undefined): OfflineDeviceRow['action'export interface ShareViewModelCallbacks {onPeerJoined?: (peer: ConnectedDeviceRow) => voidonPeerPaired?: (peer: ConnectedDeviceRow) => void+ onPeerDownloaded?: (peer: ConnectedDeviceRow) => voidonInviteFailed?: (peer: OfflineDeviceRow) => voidonPeerOutdated?: () => void}@@ -366,6 +367,17 @@ export function useShareViewModel(}prevPairActionsRef.current = new Map(connectedRows.map((row) => [row.peerKey, row.action]))}, [connectedRows])+ const prevPeerStatusesRef = useRef<Map<string, PeerListEntry['status']>>(new Map())+ useEffect(() => {+ for (const entry of peerEntries) {+ const prevStatus = prevPeerStatusesRef.current.get(entry.peerKey)+ if (prevStatus && prevStatus !== 'downloaded' && entry.status === 'downloaded') {+ const row = connectedRowsRef.current.find((r) => r.peerKey === entry.peerKey)+ if (row) callbacksRef.current.onPeerDownloaded?.(row)+ }+ }+ prevPeerStatusesRef.current = new Map(peerEntries.map((e) => [e.peerKey, e.status]))+ }, [peerEntries])const pair = (peerKey: string) => {if (transferId) requestPair(transferId, peerKey)