Remove shareable invitation links
Codes are exchanged by copy and paste again. The URL fragment intake, the invitation dialog, the BroadcastChannel answer relay and the Share link / Copy link controls are gone, along with their tests, browser check scenarios and design doc. Code fields no longer accept links. The compressed HC1 codes with typed offers/answers and echoed refs stay. An optional signaling backend is the intended way to simplify the exchange instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f320bfb541
commit
a5935a8324
16 files changed
+57
-602
No files matched your search
+4
-29
@@ -2,14 +2,9 @@
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import ConnectionWorkspace from './components/ConnectionWorkspace.vue';
|
||||
import AppDialog from './components/AppDialog.vue';
|
||||
import InvitationDialog from './components/InvitationDialog.vue';
|
||||
import { addConnection, CONNECTION_LIMIT, emptyConnection, loadConnections, removeConnection, saveConnection, updateConnection, type ConnectionUpdate, type SavedConnection } from './lib/connections.ts';
|
||||
import { takeFragment } from './lib/invitations.ts';
|
||||
import { asError } from './lib/validation.ts';
|
||||
|
||||
// A code from the link this page was opened with, already removed from the URL.
|
||||
const props = defineProps<{ initialCode?: string }>();
|
||||
|
||||
const logoUrl = `${import.meta.env.BASE_URL}HellNet_alt.png`;
|
||||
const giteaIconUrl = `${import.meta.env.BASE_URL}gitea.svg`;
|
||||
const connections = ref<SavedConnection[]>([]), selected = ref('');
|
||||
@@ -22,10 +17,6 @@ let renameContainer: HTMLElement | null = null;
|
||||
const removalTarget = computed(() => connections.value.find(item => item.id === removalId.value));
|
||||
const error = ref(''), removalError = ref('');
|
||||
const heading = ref<HTMLElement | null>(null);
|
||||
// An opened link awaiting review, and an accepted offer on its way to a slot.
|
||||
const invitation = ref<{ code: string } | null>(null);
|
||||
const handoff = ref<{ connection: string; code: string } | null>(null);
|
||||
const canAdd = computed(() => !adding.value && !removing.value && connections.value.length < CONNECTION_LIMIT);
|
||||
let persistent = true, pending = 0, writes = Promise.resolve(), refreshRequested = false;
|
||||
let updates: BroadcastChannel | undefined;
|
||||
function select(id: string) {
|
||||
@@ -81,15 +72,8 @@ onMounted(async () => {
|
||||
updates.onmessage = () => { void refresh(); };
|
||||
}
|
||||
window.addEventListener('focus', refresh);
|
||||
window.addEventListener('hashchange', openLink);
|
||||
if (props.initialCode) invitation.value = { code: props.initialCode };
|
||||
});
|
||||
onBeforeUnmount(() => { updates?.close(); window.removeEventListener('focus', refresh); window.removeEventListener('hashchange', openLink); });
|
||||
// A link opened in an existing tab only changes the fragment.
|
||||
function openLink() {
|
||||
const code = takeFragment();
|
||||
if (code) invitation.value = { code };
|
||||
}
|
||||
onBeforeUnmount(() => { updates?.close(); window.removeEventListener('focus', refresh); });
|
||||
async function add() {
|
||||
if (adding.value || removing.value || connections.value.length >= CONNECTION_LIMIT) return;
|
||||
adding.value = true;
|
||||
@@ -97,18 +81,10 @@ async function add() {
|
||||
await writes;
|
||||
if (persistent) connections.value = await addConnection();
|
||||
else connections.value.push(emptyConnection(Math.max(...connections.value.map(item => item.number)) + 1));
|
||||
const id = connections.value.at(-1)!.id;
|
||||
select(id); updates?.postMessage('changed');
|
||||
return id;
|
||||
select(connections.value.at(-1)!.id); updates?.postMessage('changed');
|
||||
} catch (err) { error.value = asError(err).message; }
|
||||
finally { adding.value = false; }
|
||||
}
|
||||
async function openInvitation(target: string, code: string) {
|
||||
const id = target === 'new' ? await add() : target;
|
||||
if (!id || !connections.value.some(item => item.id === id)) return;
|
||||
if ((states.value[id] ?? 'ready') !== 'ready') { error.value = 'That connection is in use. Open the link again and choose another connection.'; return; }
|
||||
select(id); handoff.value = { connection: id, code };
|
||||
}
|
||||
function update(id: string, change: ConnectionUpdate) {
|
||||
const index = connections.value.findIndex(item => item.id === id);
|
||||
if (index < 0) return;
|
||||
@@ -214,8 +190,8 @@ async function remove() {
|
||||
<p v-if="error" class="storage-error" role="alert">{{ error }}</p>
|
||||
<template v-for="item in connections" :key="item.id">
|
||||
<KeepAlive>
|
||||
<ConnectionWorkspace v-if="selected === item.id" :connection="item" :load-trust="trust" :invitation="handoff?.connection === item.id ? handoff : null"
|
||||
@status="setStatus" @update="update" @invitation-taken="handoff = null" />
|
||||
<ConnectionWorkspace v-if="selected === item.id" :connection="item" :load-trust="trust"
|
||||
@status="setStatus" @update="update" />
|
||||
</KeepAlive>
|
||||
</template>
|
||||
<p v-if="!current" class="status">Opening your connections…</p>
|
||||
@@ -231,5 +207,4 @@ async function remove() {
|
||||
<button class="danger" :disabled="removing" @click="remove">{{ removing ? 'Removing…' : 'Remove connection' }}</button>
|
||||
</template>
|
||||
</AppDialog>
|
||||
<InvitationDialog v-if="current" v-model="invitation" :connections="connections" :states="states" :current="current.id" :can-add="canAdd" @open="openInvitation" />
|
||||
</template>
|
||||
Reference in new issue
Block a user