Setup now waits for both IndexedDB writes: the acceptor acknowledges its write, a failure on either side is reported to both people, and the proposer removes its copy if the acceptor could not save. Every session that authenticates the paired device compares a check value derived from the stored pairing, so a one-sided pairing (interrupted setup, or Turn off reconnect on one device) is turned off on the other side too. The tracker is chosen under Network settings > Connection discovery (manual, default from VITE_TRACKER_URL, or custom), stored per browser and editable during a session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
2.4 KiB
Vue
37 lines
2.4 KiB
Vue
<script setup lang="ts">
|
|
import { ref } from 'vue';
|
|
import TransferPanel from './TransferPanel.vue';
|
|
import type { SavedConnection, ConnectionUpdate } from '../lib/connections.ts';
|
|
import type { ReconnectPairing } from '../lib/reconnect.ts';
|
|
const props = defineProps<{ connection: SavedConnection; loadTrust: (id: string) => Promise<SavedConnection>; saveReconnect: (id: string, reconnect: ReconnectPairing | null) => Promise<void> }>();
|
|
const emit = defineEmits<{
|
|
status: [id: string, state: 'ready' | 'connecting' | 'connected'];
|
|
update: [id: string, change: ConnectionUpdate];
|
|
}>();
|
|
const mode = ref<'send' | 'receive'>('send');
|
|
const sessionActive = ref(false), connected = ref(false);
|
|
const direction = ref<'send' | 'receive'>('send');
|
|
const panel = ref<InstanceType<typeof TransferPanel> | null>(null);
|
|
function status() { emit('status', props.connection.id, connected.value ? 'connected' : sessionActive.value ? 'connecting' : 'ready'); }
|
|
function navigate(next: 'send' | 'receive') {
|
|
if (connected.value) { direction.value = next; panel.value?.focusDirection(next); }
|
|
else if (!sessionActive.value) mode.value = next;
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="connection-workspace">
|
|
<div class="workspace-intro">
|
|
<h2>{{ connected ? 'Share files' : 'Start a session' }}</h2>
|
|
<p>{{ connected ? 'Your connection is ready.' : 'Exchange connection codes with your peer to start sharing.' }} Each direction sends one file at a time; both people can send on this connection.</p>
|
|
</div>
|
|
<div class="tabs" role="group" :aria-label="connected ? 'Transfer sections' : 'Connection setup'">
|
|
<button :disabled="sessionActive && !connected" :class="{ active: (connected ? direction : mode) === 'send' }" :aria-pressed="(connected ? direction : mode) === 'send'" @click="navigate('send')">Send</button>
|
|
<button :disabled="sessionActive && !connected" :class="{ active: (connected ? direction : mode) === 'receive' }" :aria-pressed="(connected ? direction : mode) === 'receive'" @click="navigate('receive')">Receive</button>
|
|
</div>
|
|
<TransferPanel ref="panel" :key="mode" :sending="mode === 'send'" :connection="connection" :load-trust="() => loadTrust(connection.id)" :save-reconnect="reconnect => saveReconnect(connection.id, reconnect)"
|
|
@session-change="sessionActive = $event; status()" @connected-change="connected = $event; direction = mode; status()"
|
|
@update="emit('update', connection.id, $event)" />
|
|
</div>
|
|
</template>
|