← back to Dw Photo Capture
Scan upload-progress (final DTD FIX-THEN-SHIP): identify-multi POST via XHR shows '⬆ Uploading photo… n%' then '🔎 Identifying…' — kills the dead-looking wait on a big raw-photo cellular upload that a user would misread as a freeze
ab7c20f74d1115fea97644b9e66f502ab86f0199 · 2026-07-08 16:03:14 -0700 · Steve Abrams
Files touched
Diff
commit ab7c20f74d1115fea97644b9e66f502ab86f0199
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Jul 8 16:03:14 2026 -0700
Scan upload-progress (final DTD FIX-THEN-SHIP): identify-multi POST via XHR shows '⬆ Uploading photo… n%' then '🔎 Identifying…' — kills the dead-looking wait on a big raw-photo cellular upload that a user would misread as a freeze
---
public/index.html | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/public/index.html b/public/index.html
index ad03f1e..a787735 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1557,10 +1557,19 @@ async function fbRead(file,isBack){ if(!file)return;
}
}
function fbVisualHtml(vis){ if(!vis||!vis.length) return ''; return '<div class="samp-meta" style="margin-top:12px">Visual matches:</div>'+vis.slice(0,4).map(v=>`<div class="fb-hit">${v.image?`<img src="${v.image}">`:''}<div><b>${v.pattern||v.dw_sku||''}</b> <small>${Math.round((v.score||0)*100)}%</small><br><small>${[v.vendor,v.dw_sku].filter(Boolean).join(' · ')}</small></div></div>`).join(''); }
+// POST JSON with real UPLOAD progress (fetch can't report it) — so a big raw-photo upload on cellular
+// shows '⬆ Uploading… n%' instead of a dead-looking wait the user misreads as a freeze.
+function postJSONup(url,obj,onUp){ return new Promise((resolve,reject)=>{
+ const xhr=new XMLHttpRequest(); xhr.open('POST',url); xhr.setRequestHeader('Content-Type','application/json');
+ if(onUp&&xhr.upload) xhr.upload.onprogress=e=>{ if(e.lengthComputable) onUp(Math.round(e.loaded/e.total*100)); };
+ xhr.onload=()=>{ try{ resolve(JSON.parse(xhr.responseText)); }catch(e){ reject(e); } };
+ xhr.onerror=()=>reject(new Error('network')); xhr.ontimeout=()=>reject(new Error('timeout')); xhr.timeout=90000;
+ xhr.send(JSON.stringify(obj)); }); }
async function fbIdentify(){
- $('#fbGo').disabled=true; $('#fbNote').textContent='Identifying…'; $('#fbResult').innerHTML='';
+ $('#fbGo').disabled=true; $('#fbNote').textContent='⬆ Uploading photo…'; $('#fbResult').innerHTML='';
try{
- const r=await(await fetch('/api/identify-multi',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({back:_fbBack,front:_fbFront,qr:_fbQR})})).json();
+ const r=await postJSONup('/api/identify-multi',{back:_fbBack,front:_fbFront,qr:_fbQR},
+ pct=>{ $('#fbNote').textContent = pct<100 ? `⬆ Uploading photo… ${pct}%` : '🔎 Identifying…'; });
// what the OCR actually read off the label (codes with a digit) — the model# is what runs down the SKU
const ocrCands=(r.back_read&&r.back_read.candidates)||[];
const ocrTop=r.code||(r.back_read&&r.back_read.top)||ocrCands[0]||'';
← dd49fa4 iOS freeze — close the contrarian gap: ALL photo flows now d
·
back to Dw Photo Capture
·
auto-save: 2026-07-09T08:39:40 (2 files) — public/index.html 036d130 →