Ask in the page's own dialog, not confirm(), which the iOS app answered Cancel (#462)

Deleting a downloaded file from the iOS app did nothing: no DELETE reached ipx-web or ipx.
WKWebView answers confirm() Cancel without showing it unless the app implements the panel,
which 614f270 does (#453), but only once the app is rebuilt. ask() is a <dialog> of the
page's own, in the top layer, so it opens over a dialog already up (the file menu, Settings)
and leaves it as it was, and Escape answers it alone. Every confirm() in the page and the
admin page goes through it; the tests answer it rather than the browser's dialog, and the
warning before sharing a feed with its key in the address, untested before, now is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 23:32:15 +00:00
parent d1ba83bb7a
commit eda77e87c7
9 changed files with 77 additions and 36 deletions

View File

@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Deleting a downloaded file, marking everything read, deleting a signal and the other actions that ask first now ask in the page's own dialog, so they go ahead in the iOS app, which answered the browser's question Cancel without showing it (#462).
- A page kept for offline from before a deploy, shown on waking before the network was back, is loaded again rather than run with the new script, which left it dead until reloaded by hand (#449).
- On a phone the totals along the bottom (All Subscriptions: N items, N unread) are text alone, centred just above the home indicator, instead of a band and rule that ran to the bottom edge and were cut off by the screen's rounded corners (#424).
- The admin page's top bar clears the status bar in the iOS app, so its back button can be tapped; the page asked for no room under the clock as the app page does (#423).

View File

@@ -1152,6 +1152,10 @@ input[type=range]::-moz-range-thumb{width:12px;height:12px;border:0;border-radiu
overscroll-behavior:contain;
}
.card.wide{width:min(1000px,100%)}
/* The page's own question before something hard to take back (#462): over any dialog already up. */
dialog.ask{color:inherit;margin:auto;width:min(420px,calc(100% - 32px))}
dialog.ask::backdrop{background:rgba(0,0,0,.6)}
dialog.ask p{margin:0;line-height:1.45}
#logbox{
background:var(--bg);border:1px solid var(--line);border-radius:9px;padding:10px 12px;
height:min(60vh,520px);overflow:auto;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;
@@ -1519,6 +1523,8 @@ body:has(#player.on) #status{padding-bottom:3px}
width:100%;max-height:calc(100dvh - var(--safe-t) - 12px);border-color:var(--edge);border-radius:20px 20px 0 0;
padding:20px 16px calc(20px + var(--safe-b));animation:sheet .3s cubic-bezier(.2,.8,.2,1);
}
/* A sheet, as every dialog is here. */
dialog.ask{margin:auto 0 0;width:100%;max-width:100%}
.card h3{font-size:22px}
.field label,.field .hint{font-size:13px}
.check{font-size:17px}

View File

@@ -191,7 +191,7 @@ async function drawDirectoryAdmin(){
try{
if(b.dataset.a === 'drop'){
const name = row!.dataset.name!;
if(!confirm(`Drop ${name}'s feeds and counts from the directory? They come back the next time ${name} shares.`)) return;
if(!await ask(`Drop ${name}'s feeds and counts from the directory? They come back the next time ${name} shares.`, 'Drop')) return;
await api(`/api/directory-instances/${encodeURIComponent(name)}`, {method: 'DELETE'});
toast(`Dropped ${name}'s snapshot`);
}else if(b.dataset.a === 'unblock'){
@@ -235,8 +235,8 @@ async function drawAccounts(){
const u = users.find(x => String(x.id) === row.dataset.id)!;
$('[data-a="admin"]', row).onchange = (e: Event) =>
change(u, {method: 'PATCH', body: JSON.stringify({admin: (e.target as HTMLInputElement).checked})});
$('[data-a="rm"]', row).onclick = () => {
if(confirm(`Remove ${u.name}? Their subscriptions and read state go with them. Downloaded files stay.`))
$('[data-a="rm"]', row).onclick = async () => {
if(await ask(`Remove ${u.name}? Their subscriptions and read state go with them. Downloaded files stay.`, 'Remove'))
change(u, {method: 'DELETE'});
};
}

View File

@@ -269,7 +269,7 @@ async function fillShow(box: HTMLElement,p: DirFeed){
catch(e){ toast(why(e),true); }
};
$('[data-a="dremove"]',acts).onclick=async()=>{
if(!confirm(`Remove ${NAME(p)} from the directory? It is blocked, so no server's snapshot brings it back. Admin, Directory can unblock it.`)) return;
if(!await ask(`Remove ${NAME(p)} from the directory? It is blocked, so no server's snapshot brings it back. Admin, Directory can unblock it.`, 'Remove')) return;
try{ await api(`/api/directory/${encodeURIComponent(p.id)}`,{method:'DELETE'}); }
catch(e){ return toast(why(e),true); }
toast(`Removed ${NAME(p)} from the directory`);
@@ -531,11 +531,11 @@ async function prefsModal(){
renderFeeds();
}catch(err){ toast(why(err),true); }
};
$<HTMLInputElement>('#ssigon').onchange=(e: Event)=>{
$<HTMLInputElement>('#ssigon').onchange=async(e: Event)=>{
const on=(e.target as HTMLInputElement).checked;
if(on){ $('#ssigkey').hidden=false; $<HTMLInputElement>('#stskey').focus(); return; }
if(!S.me?.typesafe_key_set){ $('#ssigkey').hidden=true; return; }
if(confirm('Turn Signals off and forget your TypeSafe key? Your signals are kept for when you turn them on again.')) saveKey(null);
if(await ask('Turn Signals off and forget your TypeSafe key? Your signals are kept for when you turn them on again.', 'Turn off')) saveKey(null);
else (e.target as HTMLInputElement).checked=true;
};
$<HTMLInputElement>('#stskey').onchange=(e: Event)=>{ const k=(e.target as HTMLInputElement).value.trim(); if(k) saveKey(k); };

View File

@@ -187,7 +187,7 @@ async function allAction(a: string){
const n=S.feeds.reduce((k,x)=>k+(x.unread||0),0);
if(!n){ toast('Nothing unread'); return; }
// One click across every feed is a lot to take back, so this one asks first.
if(!confirm(`Mark all ${n} unread item${n===1?'':'s'} read, in every feed you subscribe to?`)) return;
if(!await ask(`Mark all ${n} unread item${n===1?'':'s'} read, in every feed you subscribe to?`, 'Mark all read')) return;
try{
const r=await api('/api/read-all',{method:'POST'});
haptic('done'); toast(`Marked ${r.marked} read`); await loadFeeds(true); renderFeed(); loadEntries();

View File

@@ -594,7 +594,7 @@ async function shareEpisode(e: Entry, encId: number|null){
const at=!link.url ? 0 : player.guid===e.guid && player.feed===e.feed_id ? audio.currentTime : e.position;
// A menu rather than the share sheet at once, for the item's own address too: the sheet needs a
// press of its own, and the request above has used up the one that opened this (#452). The
// warning is written here, not asked with confirm(), which the iOS app answers Cancel (#453).
// warning is written here, not asked first, since it is in the menu anyway.
openModal(`<button class="iconbtn cardx" onclick="closeModal()" title="Close" aria-label="Close">${ICON.close}</button>
<h3>Share</h3><p class="hint">${esc(name)}</p>
${link.url ? '' : noLinkNote(link.why, url)}
@@ -641,17 +641,17 @@ async function epAction(a: string, e: Entry, el: HTMLElement|null, encId?: numbe
if(a==='del'){
const f=S.feeds.find(x=>x.id===e.feed_id);
const shared=f&&f.subscribers>1;
if(!confirm(shared
? `Delete this file?\n\nThere is one copy, shared with ${f.subscribers-1} other `
if(!await ask(shared
? `Delete this file? There is one copy, shared with ${f.subscribers-1} other `
+`${f.subscribers===2?'person':'people'} reading this feed. The item stays listed `
+`and will not be downloaded again automatically.`
: 'Delete the downloaded file?\n\nThe item stays listed and will not be downloaded again automatically.')) return;
: 'Delete the downloaded file? The item stays listed and will not be downloaded again automatically.', 'Delete')) return;
try{
await api(`/api/enclosures/${enc.id}`,{method:'DELETE'});
}catch(err){
// 409: somebody else has it starred or unplayed. Their reason, their words.
if(!/one copy of this file/.test(why(err))) throw err;
if(!confirm(why(err)+'\n\nDelete it anyway?')) return;
if(!await ask(why(err), 'Delete it anyway')) return;
await api(`/api/enclosures/${enc.id}?force=true`,{method:'DELETE'});
}
toast('Deleted'); loadEntries(); loadFeeds(true);

View File

@@ -126,7 +126,7 @@ function signalHead(sg: Signal){
async function signalAction(a: string, sg: Signal){
if(a==='settings') signalModal(sg);
if(a==='rm'){
if(!confirm(`Delete the signal ${sg.name}? The items stay in their own feeds.`)) return;
if(!await ask(`Delete the signal ${sg.name}? The items stay in their own feeds.`, 'Delete')) return;
try{
await api(`/api/signals/${sg.id}`,{method:'DELETE'});
toast('Deleted'); await loadFeeds(true); selectFeed(':all');

View File

@@ -18,6 +18,26 @@ function asLink(el: HTMLElement, current: boolean){
}
const ESCAPED: Record<string,string> ={'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'};
const esc = (s: string|null|undefined) => (s??'').replace(/[&<>"']/g,c=>ESCAPED[c]);
/// Asks before something hard to take back, in a dialog of the page's own. Not confirm(): the iOS
/// app answered that Cancel without showing it, so nothing that asked first went ahead there
/// (#453, #462). A <dialog> of its own, in the top layer, so it opens over a dialog already up and
/// leaves it as it was; Escape or a tap on Cancel answers no.
function ask(text: string, yes: string): Promise<boolean>{
const d=document.createElement('dialog');
d.className='card ask';
d.innerHTML=`<p></p><div class="cardacts"><button type="button" class="btn" value="">Cancel</button>
<button type="button" class="btn danger" value="y"></button></div>`;
d.querySelector('p')!.textContent=text;
d.querySelector('[value="y"]')!.textContent=yes;
document.body.append(d);
return new Promise(done=>{
d.onclick=(e: MouseEvent)=>{ const b=(e.target as Element).closest('button'); if(b) d.close(b.value); };
// Escape answers this dialog alone, not the one under it too.
d.onkeydown=(e: KeyboardEvent)=>{ if(e.key==='Escape') e.stopPropagation(); };
d.onclose=()=>{ d.remove(); done(d.returnValue==='y'); };
d.showModal();
});
}
// A feed's link, only if it is a web address: esc() keeps a javascript: or data: one working (#326).
const webUrl = (u: string|null|undefined): string|null => /^https?:\/\//i.test(u??'') ? u! : null;
// Icons: Font Awesome Free 7.3.1 by @fontawesome - https://fontawesome.com
@@ -213,7 +233,7 @@ async function copyText(text: string,btn?: HTMLElement){
/// ponytail: a guess from the address. A private feed whose key has another name is shared
/// without asking; add its pattern here when one turns up.
async function share(title: string, url: string, btn?: HTMLElement){
if(carriesAccess(url) && !confirm(ACCESS_WARNING+'\n\nShare it anyway?')) return;
if(carriesAccess(url) && !await ask(ACCESS_WARNING, 'Share it anyway')) return;
await sendLink(title, url, btn);
}