fix interactive bug
This commit is contained in:
+6
-14
@@ -227,21 +227,13 @@ async function handleEnter() {
|
||||
return;
|
||||
}
|
||||
|
||||
// First, check if this URL already exists
|
||||
setStatus('checking…', '');
|
||||
try {
|
||||
const lookupRes = await apiGet('/api/lookup?url=' + encodeURIComponent(url));
|
||||
if (lookupRes.ok) {
|
||||
// URL already exists — just show its metadata
|
||||
const data = await lookupRes.json();
|
||||
state.currentMeta = data;
|
||||
renderMeta(data);
|
||||
setStatus('exists', 'ok');
|
||||
return;
|
||||
}
|
||||
} catch { /* lookup failed, proceed to create */ }
|
||||
// If the debounced lookup already found this URL exists, just show it
|
||||
if (state.currentMeta && state.currentMeta.original_url === url) {
|
||||
setStatus('exists', 'ok');
|
||||
return;
|
||||
}
|
||||
|
||||
// URL does not exist — attempt to create
|
||||
// Create a new short URL
|
||||
setStatus('creating…', '');
|
||||
try {
|
||||
const res = await apiPost('/api/shorten', { url: url });
|
||||
|
||||
Reference in New Issue
Block a user