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:
@@ -10,6 +10,8 @@ import type { Locator, Page, Request } from '@playwright/test';
|
|||||||
declare global {
|
declare global {
|
||||||
interface Window { started: string[]; done: boolean; shared: ShareData[] }
|
interface Window { started: string[]; done: boolean; shared: ShareData[] }
|
||||||
}
|
}
|
||||||
|
/// Answers the page's own question (#462): yes, or Cancel.
|
||||||
|
const answer = (page: Page, yes = true) => page.locator(`dialog.ask [value="${yes ? 'y' : ''}"]`).click();
|
||||||
/// What a failed `ipx` command said, from execFileSync's error.
|
/// What a failed `ipx` command said, from execFileSync's error.
|
||||||
const said = (e: unknown) => { const x = e as { stderr?: unknown, stdout?: unknown }; return String(x.stderr || x.stdout); };
|
const said = (e: unknown) => { const x = e as { stderr?: unknown, stdout?: unknown }; return String(x.stderr || x.stdout); };
|
||||||
|
|
||||||
@@ -865,18 +867,15 @@ test('deleting a shared file warns that it is everyone\'s copy', async ({ page }
|
|||||||
const del = page.locator('#modalCard [data-m="del"]');
|
const del = page.locator('#modalCard [data-m="del"]');
|
||||||
await expect(del).toHaveText(/^Delete from iPX, for everyone \(shared with 1 other person/);
|
await expect(del).toHaveText(/^Delete from iPX, for everyone \(shared with 1 other person/);
|
||||||
|
|
||||||
// Two prompts: the page's own, then the server's, because someone else has not played
|
// Two questions: the page's own, then the server's, because someone else has not played
|
||||||
// it. Accept the first, decline the second, and the file must survive.
|
// it. Yes to the first, Cancel to the second, and the file must survive.
|
||||||
const seen: string[] = [];
|
|
||||||
page.on('dialog', d => {
|
|
||||||
seen.push(d.message());
|
|
||||||
if (seen.length === 1) d.accept();
|
|
||||||
else d.dismiss();
|
|
||||||
});
|
|
||||||
await del.click();
|
await del.click();
|
||||||
await expect.poll(() => seen.length, { timeout: 10_000 }).toBe(2);
|
const ask = page.locator('dialog.ask');
|
||||||
expect(seen[0]).toContain('shared with 1 other person');
|
await expect(ask).toContainText('shared with 1 other person');
|
||||||
expect(seen[1]).toContain('one copy of this file');
|
await answer(page);
|
||||||
|
await expect(ask).toContainText('one copy of this file');
|
||||||
|
await answer(page, false);
|
||||||
|
await expect(ask).toHaveCount(0);
|
||||||
|
|
||||||
await page.reload();
|
await page.reload();
|
||||||
await page.locator('.feed', { hasText: 'Test Show' }).click();
|
await page.locator('.feed', { hasText: 'Test Show' }).click();
|
||||||
@@ -913,8 +912,8 @@ test('an admin adds someone, makes them an admin, and removes them', async ({ pa
|
|||||||
(await (await page.request.get('/api/users')).json()).find((u: Account) => u.name === 'pat')?.admin
|
(await (await page.request.get('/api/users')).json()).find((u: Account) => u.name === 'pat')?.admin
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
|
|
||||||
page.once('dialog', d => d.accept());
|
|
||||||
await row.locator('[data-a="rm"]').click();
|
await row.locator('[data-a="rm"]').click();
|
||||||
|
await answer(page);
|
||||||
await expect(row).toHaveCount(0);
|
await expect(row).toHaveCount(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1494,14 +1493,15 @@ test('the player keeps its speed and volume, marks an item played to its end rea
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('a deleted file looks as if it was never downloaded', async ({ page }) => {
|
test('a deleted file looks as if it was never downloaded', async ({ page }) => {
|
||||||
// Other people subscribe to Picture Blog by now, so both prompts come; take them.
|
// Other people subscribe to Picture Blog by now, so both questions come; yes to each.
|
||||||
page.on('dialog', d => d.accept());
|
|
||||||
await page.locator('.feed', { hasText: 'Picture Blog' }).click();
|
await page.locator('.feed', { hasText: 'Picture Blog' }).click();
|
||||||
const row = page.locator('.ep', { hasText: 'An Article' });
|
const row = page.locator('.ep', { hasText: 'An Article' });
|
||||||
await expect(row).toBeVisible({ timeout: 20_000 });
|
await expect(row).toBeVisible({ timeout: 20_000 });
|
||||||
await row.click();
|
await row.click();
|
||||||
await page.locator('#files .encbox [data-a="more"]').last().click();
|
await page.locator('#files .encbox [data-a="more"]').last().click();
|
||||||
await page.locator('#modalCard [data-m="del"]').click();
|
await page.locator('#modalCard [data-m="del"]').click();
|
||||||
|
await answer(page);
|
||||||
|
await answer(page);
|
||||||
|
|
||||||
// No "reaped", no chip at all: just the way to get it again.
|
// No "reaped", no chip at all: just the way to get it again.
|
||||||
await expect(row.locator('.kind.here')).toHaveCount(0);
|
await expect(row.locator('.kind.here')).toHaveCount(0);
|
||||||
@@ -1575,8 +1575,8 @@ test('All Subscriptions marks everything read, across every feed', async ({ page
|
|||||||
await expect(page.locator('#epSearch')).toHaveAttribute('placeholder', 'Search');
|
await expect(page.locator('#epSearch')).toHaveAttribute('placeholder', 'Search');
|
||||||
await expect(page.locator('#epSearch')).toHaveAccessibleName('Search All Subscriptions');
|
await expect(page.locator('#epSearch')).toHaveAccessibleName('Search All Subscriptions');
|
||||||
|
|
||||||
page.once('dialog', d => d.accept());
|
|
||||||
await page.locator('#content .acts [data-a="readall"]').click();
|
await page.locator('#content .acts [data-a="readall"]').click();
|
||||||
|
await answer(page);
|
||||||
await expect(all.locator('.badge')).toHaveText('0');
|
await expect(all.locator('.badge')).toHaveText('0');
|
||||||
await page.locator('.tabs button', { hasText: 'Unread' }).click();
|
await page.locator('.tabs button', { hasText: 'Unread' }).click();
|
||||||
await expect(page.locator('.ep')).toHaveCount(0);
|
await expect(page.locator('.ep')).toHaveCount(0);
|
||||||
@@ -1880,8 +1880,8 @@ test('an admin removes a feed from the directory, and unblocks it (#206)', async
|
|||||||
await piper.locator('.show [data-a="drefresh"]').click();
|
await piper.locator('.show [data-a="drefresh"]').click();
|
||||||
await expect(piper.locator('.toast', { hasText: 'Checked' })).toBeVisible();
|
await expect(piper.locator('.toast', { hasText: 'Checked' })).toBeVisible();
|
||||||
await expect(piper.locator('.show [data-a="dremove"]')).toHaveCount(1);
|
await expect(piper.locator('.show [data-a="dremove"]')).toHaveCount(1);
|
||||||
piper.once('dialog', d => d.accept());
|
|
||||||
await piper.locator('.show [data-a="dremove"]').click();
|
await piper.locator('.show [data-a="dremove"]').click();
|
||||||
|
await answer(piper);
|
||||||
await expect(piper.locator('.show h2')).toHaveCount(0);
|
await expect(piper.locator('.show h2')).toHaveCount(0);
|
||||||
expect(await listed()).not.toContain('Aardvark Radio');
|
expect(await listed()).not.toContain('Aardvark Radio');
|
||||||
} finally {
|
} finally {
|
||||||
@@ -2318,10 +2318,8 @@ test('Share hands the feed, and an episode as a link to its page on ipx-play (#4
|
|||||||
const paid = await page.evaluate(() => api('/api/entries/paid-show/paid-1/share', { method: 'POST', body: '{}' }));
|
const paid = await page.evaluate(() => api('/api/entries/paid-show/paid-1/share', { method: 'POST', body: '{}' }));
|
||||||
expect(paid).toEqual({ url: null, why: 'private' });
|
expect(paid).toEqual({ url: null, why: 'private' });
|
||||||
// Through the same menu all the same: the sheet needs a press of its own after that request
|
// Through the same menu all the same: the sheet needs a press of its own after that request
|
||||||
// (#452), and a key in the address is warned of there, not asked with confirm(), which the iOS
|
// (#452), and a key in the address is warned of there rather than asked first.
|
||||||
// app answers Cancel (#453).
|
|
||||||
await page.evaluate(async () => {
|
await page.evaluate(async () => {
|
||||||
window.confirm = () => false;
|
|
||||||
const e = (await api('/api/feeds/paid-show/entries') as ListPage).entries[0];
|
const e = (await api('/api/feeds/paid-show/entries') as ListPage).entries[0];
|
||||||
await shareEpisode({ ...e, link: 'https://www.patreon.com/posts/1?auth=secret123' }, null);
|
await shareEpisode({ ...e, link: 'https://www.patreon.com/posts/1?auth=secret123' }, null);
|
||||||
});
|
});
|
||||||
@@ -2341,6 +2339,22 @@ test('Share hands the feed, and an episode as a link to its page on ipx-play (#4
|
|||||||
await expect(page.locator('#modalCard')).not.toContainText('own access');
|
await expect(page.locator('#modalCard')).not.toContainText('own access');
|
||||||
await page.locator('#shlink').click();
|
await page.locator('#shlink').click();
|
||||||
await expect.poll(() => page.evaluate(() => window.shared.at(-1)?.url)).toBe('https://www.patreon.com/glasscannon/posts/1');
|
await expect.poll(() => page.evaluate(() => window.shared.at(-1)?.url)).toBe('https://www.patreon.com/glasscannon/posts/1');
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
|
||||||
|
// A feed whose address carries its key is asked about first, in the page's own dialog (#462):
|
||||||
|
// Cancel shares nothing, and Escape closes the question alone.
|
||||||
|
const before = await page.evaluate(() => window.shared.length);
|
||||||
|
await page.locator('.feed', { hasText: 'Paid Show' }).click();
|
||||||
|
await page.locator('#content .acts [data-a="share"]').click();
|
||||||
|
await expect(page.locator('dialog.ask')).toContainText('includes your own access');
|
||||||
|
await answer(page, false);
|
||||||
|
await page.locator('#content .acts [data-a="share"]').click();
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
await expect(page.locator('dialog.ask')).toHaveCount(0);
|
||||||
|
expect(await page.evaluate(() => window.shared.length)).toBe(before);
|
||||||
|
await page.locator('#content .acts [data-a="share"]').click();
|
||||||
|
await answer(page);
|
||||||
|
await expect.poll(() => page.evaluate(() => window.shared.at(-1)?.url)).toBe('http://127.0.0.1:8792/paid.xml?auth=secret123');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('a refresh button turns from the press to the end of the scan it asked for', async ({ page }) => {
|
test('a refresh button turns from the press to the end of the scan it asked for', async ({ page }) => {
|
||||||
@@ -2771,8 +2785,8 @@ signalsTest('a Signal is renamed from its own page and deleted from there', asyn
|
|||||||
const one = async () => (await (await page.request.get('/api/signals')).json() as Signal[]).find(s => s.id === id);
|
const one = async () => (await (await page.request.get('/api/signals')).json() as Signal[]).find(s => s.id === id);
|
||||||
expect((await one())?.name).toBe('Bread and cakes');
|
expect((await one())?.name).toBe('Bread and cakes');
|
||||||
|
|
||||||
page.once('dialog', d => d.accept());
|
|
||||||
await page.locator('#content [data-a="rm"]').click();
|
await page.locator('#content [data-a="rm"]').click();
|
||||||
|
await answer(page);
|
||||||
await expect(page.locator('.toast', { hasText: 'Deleted' })).toBeVisible();
|
await expect(page.locator('.toast', { hasText: 'Deleted' })).toBeVisible();
|
||||||
await expect(page.locator('#feedlist .feed.child', { hasText: 'Bread and cakes' })).toHaveCount(0);
|
await expect(page.locator('#feedlist .feed.child', { hasText: 'Bread and cakes' })).toHaveCount(0);
|
||||||
expect(await one()).toBeUndefined();
|
expect(await one()).toBeUndefined();
|
||||||
@@ -2798,8 +2812,8 @@ signalsTest('Signals are turned on in Settings with a key TypeSafe takes, and of
|
|||||||
await page.locator('#stskey').fill('test-key');
|
await page.locator('#stskey').fill('test-key');
|
||||||
await page.locator('#stskey').blur();
|
await page.locator('#stskey').blur();
|
||||||
await expect(page.locator('#feedlist .sigs')).toHaveCount(1);
|
await expect(page.locator('#feedlist .sigs')).toHaveCount(1);
|
||||||
page.once('dialog', d => d.accept());
|
await page.locator('#ssigon').click();
|
||||||
await page.locator('#ssigon').uncheck();
|
await answer(page);
|
||||||
await expect(page.locator('#feedlist .sigs')).toHaveCount(0);
|
await expect(page.locator('#feedlist .sigs')).toHaveCount(0);
|
||||||
expect((await (await page.request.get('/api/me')).json()).typesafe_key_set).toBe(false);
|
expect((await (await page.request.get('/api/me')).json()).typesafe_key_set).toBe(false);
|
||||||
await page.keyboard.press('Escape');
|
await page.keyboard.press('Escape');
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### 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).
|
- 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).
|
- 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).
|
- 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).
|
||||||
|
|||||||
@@ -1152,6 +1152,10 @@ input[type=range]::-moz-range-thumb{width:12px;height:12px;border:0;border-radiu
|
|||||||
overscroll-behavior:contain;
|
overscroll-behavior:contain;
|
||||||
}
|
}
|
||||||
.card.wide{width:min(1000px,100%)}
|
.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{
|
#logbox{
|
||||||
background:var(--bg);border:1px solid var(--line);border-radius:9px;padding:10px 12px;
|
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;
|
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;
|
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);
|
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}
|
.card h3{font-size:22px}
|
||||||
.field label,.field .hint{font-size:13px}
|
.field label,.field .hint{font-size:13px}
|
||||||
.check{font-size:17px}
|
.check{font-size:17px}
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ async function drawDirectoryAdmin(){
|
|||||||
try{
|
try{
|
||||||
if(b.dataset.a === 'drop'){
|
if(b.dataset.a === 'drop'){
|
||||||
const name = row!.dataset.name!;
|
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'});
|
await api(`/api/directory-instances/${encodeURIComponent(name)}`, {method: 'DELETE'});
|
||||||
toast(`Dropped ${name}'s snapshot`);
|
toast(`Dropped ${name}'s snapshot`);
|
||||||
}else if(b.dataset.a === 'unblock'){
|
}else if(b.dataset.a === 'unblock'){
|
||||||
@@ -235,8 +235,8 @@ async function drawAccounts(){
|
|||||||
const u = users.find(x => String(x.id) === row.dataset.id)!;
|
const u = users.find(x => String(x.id) === row.dataset.id)!;
|
||||||
$('[data-a="admin"]', row).onchange = (e: Event) =>
|
$('[data-a="admin"]', row).onchange = (e: Event) =>
|
||||||
change(u, {method: 'PATCH', body: JSON.stringify({admin: (e.target as HTMLInputElement).checked})});
|
change(u, {method: 'PATCH', body: JSON.stringify({admin: (e.target as HTMLInputElement).checked})});
|
||||||
$('[data-a="rm"]', row).onclick = () => {
|
$('[data-a="rm"]', row).onclick = async () => {
|
||||||
if(confirm(`Remove ${u.name}? Their subscriptions and read state go with them. Downloaded files stay.`))
|
if(await ask(`Remove ${u.name}? Their subscriptions and read state go with them. Downloaded files stay.`, 'Remove'))
|
||||||
change(u, {method: 'DELETE'});
|
change(u, {method: 'DELETE'});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ async function fillShow(box: HTMLElement,p: DirFeed){
|
|||||||
catch(e){ toast(why(e),true); }
|
catch(e){ toast(why(e),true); }
|
||||||
};
|
};
|
||||||
$('[data-a="dremove"]',acts).onclick=async()=>{
|
$('[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'}); }
|
try{ await api(`/api/directory/${encodeURIComponent(p.id)}`,{method:'DELETE'}); }
|
||||||
catch(e){ return toast(why(e),true); }
|
catch(e){ return toast(why(e),true); }
|
||||||
toast(`Removed ${NAME(p)} from the directory`);
|
toast(`Removed ${NAME(p)} from the directory`);
|
||||||
@@ -531,11 +531,11 @@ async function prefsModal(){
|
|||||||
renderFeeds();
|
renderFeeds();
|
||||||
}catch(err){ toast(why(err),true); }
|
}catch(err){ toast(why(err),true); }
|
||||||
};
|
};
|
||||||
$<HTMLInputElement>('#ssigon').onchange=(e: Event)=>{
|
$<HTMLInputElement>('#ssigon').onchange=async(e: Event)=>{
|
||||||
const on=(e.target as HTMLInputElement).checked;
|
const on=(e.target as HTMLInputElement).checked;
|
||||||
if(on){ $('#ssigkey').hidden=false; $<HTMLInputElement>('#stskey').focus(); return; }
|
if(on){ $('#ssigkey').hidden=false; $<HTMLInputElement>('#stskey').focus(); return; }
|
||||||
if(!S.me?.typesafe_key_set){ $('#ssigkey').hidden=true; 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;
|
else (e.target as HTMLInputElement).checked=true;
|
||||||
};
|
};
|
||||||
$<HTMLInputElement>('#stskey').onchange=(e: Event)=>{ const k=(e.target as HTMLInputElement).value.trim(); if(k) saveKey(k); };
|
$<HTMLInputElement>('#stskey').onchange=(e: Event)=>{ const k=(e.target as HTMLInputElement).value.trim(); if(k) saveKey(k); };
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ async function allAction(a: string){
|
|||||||
const n=S.feeds.reduce((k,x)=>k+(x.unread||0),0);
|
const n=S.feeds.reduce((k,x)=>k+(x.unread||0),0);
|
||||||
if(!n){ toast('Nothing unread'); return; }
|
if(!n){ toast('Nothing unread'); return; }
|
||||||
// One click across every feed is a lot to take back, so this one asks first.
|
// 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{
|
try{
|
||||||
const r=await api('/api/read-all',{method:'POST'});
|
const r=await api('/api/read-all',{method:'POST'});
|
||||||
haptic('done'); toast(`Marked ${r.marked} read`); await loadFeeds(true); renderFeed(); loadEntries();
|
haptic('done'); toast(`Marked ${r.marked} read`); await loadFeeds(true); renderFeed(); loadEntries();
|
||||||
|
|||||||
@@ -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;
|
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
|
// 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
|
// 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>
|
openModal(`<button class="iconbtn cardx" onclick="closeModal()" title="Close" aria-label="Close">${ICON.close}</button>
|
||||||
<h3>Share</h3><p class="hint">${esc(name)}</p>
|
<h3>Share</h3><p class="hint">${esc(name)}</p>
|
||||||
${link.url ? '' : noLinkNote(link.why, url)}
|
${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'){
|
if(a==='del'){
|
||||||
const f=S.feeds.find(x=>x.id===e.feed_id);
|
const f=S.feeds.find(x=>x.id===e.feed_id);
|
||||||
const shared=f&&f.subscribers>1;
|
const shared=f&&f.subscribers>1;
|
||||||
if(!confirm(shared
|
if(!await ask(shared
|
||||||
? `Delete this file?\n\nThere is one copy, shared with ${f.subscribers-1} other `
|
? `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 `
|
+`${f.subscribers===2?'person':'people'} reading this feed. The item stays listed `
|
||||||
+`and will not be downloaded again automatically.`
|
+`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{
|
try{
|
||||||
await api(`/api/enclosures/${enc.id}`,{method:'DELETE'});
|
await api(`/api/enclosures/${enc.id}`,{method:'DELETE'});
|
||||||
}catch(err){
|
}catch(err){
|
||||||
// 409: somebody else has it starred or unplayed. Their reason, their words.
|
// 409: somebody else has it starred or unplayed. Their reason, their words.
|
||||||
if(!/one copy of this file/.test(why(err))) throw err;
|
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'});
|
await api(`/api/enclosures/${enc.id}?force=true`,{method:'DELETE'});
|
||||||
}
|
}
|
||||||
toast('Deleted'); loadEntries(); loadFeeds(true);
|
toast('Deleted'); loadEntries(); loadFeeds(true);
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ function signalHead(sg: Signal){
|
|||||||
async function signalAction(a: string, sg: Signal){
|
async function signalAction(a: string, sg: Signal){
|
||||||
if(a==='settings') signalModal(sg);
|
if(a==='settings') signalModal(sg);
|
||||||
if(a==='rm'){
|
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{
|
try{
|
||||||
await api(`/api/signals/${sg.id}`,{method:'DELETE'});
|
await api(`/api/signals/${sg.id}`,{method:'DELETE'});
|
||||||
toast('Deleted'); await loadFeeds(true); selectFeed(':all');
|
toast('Deleted'); await loadFeeds(true); selectFeed(':all');
|
||||||
|
|||||||
@@ -18,6 +18,26 @@ function asLink(el: HTMLElement, current: boolean){
|
|||||||
}
|
}
|
||||||
const ESCAPED: Record<string,string> ={'&':'&','<':'<','>':'>','"':'"',"'":'''};
|
const ESCAPED: Record<string,string> ={'&':'&','<':'<','>':'>','"':'"',"'":'''};
|
||||||
const esc = (s: string|null|undefined) => (s??'').replace(/[&<>"']/g,c=>ESCAPED[c]);
|
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).
|
// 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;
|
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
|
// 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
|
/// 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.
|
/// without asking; add its pattern here when one turns up.
|
||||||
async function share(title: string, url: string, btn?: HTMLElement){
|
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);
|
await sendLink(title, url, btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user