diff --git a/pb_public/index.html b/pb_public/index.html index 13fe39a..9d9200b 100644 --- a/pb_public/index.html +++ b/pb_public/index.html @@ -1111,15 +1111,44 @@ $("adUnlock").onclick=async function(){ $("acChange").disabled=false; }; +// One account, one set of sources. The app used to keep a copy per profile, +// so an account that ever switched profile holds several copies that drifted +// apart: sources edited here reached only the first, and a child profile went +// on without webshare. Read every copy and show one answer. The newest value +// wins per field, except the Czech addon URL, where the longer one wins: it is +// the one that carries webshare's credentials as well as prehraj.to's. +function mergeConfigs(list){ + var sorted=list.slice().sort(function(a,b){ + return String(b.updatedAt||"").localeCompare(String(a.updatedAt||"")); }); + var out={}; + sorted.forEach(function(e){ + Object.keys(e.cfg||{}).forEach(function(k){ + var v=e.cfg[k]; + if ((out[k]==null || out[k]==="") && v!=null && v!=="") out[k]=v; + }); + }); + var longest=""; + list.forEach(function(e){ + var u=(e.cfg||{}).czechAddonUrl||""; + if (u.length>longest.length) longest=u; + }); + if (longest) out.czechAddonUrl=longest; + return out; +} + async function loadAddons(){ var r=await api("GET","/api/collections/addon_config/records?perPage=200"); CONFIGS = r.ok ? (r.data.items||[]) : []; cfgRec = CONFIGS[0] || null; cfg=null; - if (cfgRec){ - try { cfg=JSON.parse(await decryptBlob(cfgRec.blob, PASSWORD, cfgRec.salt)); } - catch(_){ cfg=null; } + var opened=[]; + for (var i=0;i0 && failed===0; + setMsg($("adMsg"), ok ? "Zdroje uloženy. Aplikace si je stáhne sama." + : "Uložení selhalo.", ok?"ok":"err"); + if (wrote>0) await loadAddons(); } $("adSave").onclick=async function(){