Skip to content

Commit 65282ef

Browse files
committed
fix: Download in a chat's frame that saves nothing opens a tab that saves the package, or says the way by hand (#114)
A chat's frame may drop the page's own download with nothing said, and nothing tells a page that it does: in Grok a press on Download did nothing. So a framed page does not count on its own download where the parent does not save for it. Where the parent opens links and a tab can build the package, Download hands the parent a link to a tab that builds and saves it; elsewhere the browser is left to try, and the way that works in any frame is said under the stage.
1 parent d57549b commit 65282ef

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

‎src/h5p/play/play-page.ts‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ import { baseName, compactSource, fragmentFromSource, fragmentWithLinks, kindOf,
3333
* again (#100). A link of this page opens nothing there on a press, so a parent that opens links
3434
* says so too, and is handed the address.
3535
*
36+
* A parent may save no file for the page, in a frame that drops the page's own download all the
37+
* same: in Grok a press on Download did nothing, with nothing said (2026-11-25, #114), and nothing
38+
* tells a page that its frame drops a download. So a framed page does not count on its own: where
39+
* the parent opens links and a tab can build the package, from its source and the addresses of its
40+
* files, Download hands the parent a link to a tab that saves it, as below; elsewhere the browser
41+
* is left to try, and the way by hand is said under the stage at the press.
42+
*
3643
* One press is asked for all the same (#102), and a package built in a frame cannot be passed to
3744
* a tab: the browser keeps a framed page's storage apart. But a tab can build it again from what
3845
* the frame had, the source and the files' addresses, where the store behind the addresses answers
@@ -378,6 +385,16 @@ const savingLink = (): string => `${location.origin}${location.pathname}${fragme
378385
*/
379386
const BY_HAND = 'To save it, right-click Download, or press and hold it, and open the link in a new tab.'
380387

388+
/** The way by hand, said after something else: with no "To save it" of its own. */
389+
const BY_HAND_TOO = 'Right-click Download, or press and hold it, and open the link in a new tab.'
390+
391+
/**
392+
* Whether a tab of this page could build the package that plays: every file the source names is
393+
* at an address the parent gave, or it names none. A file the person chose here is in this frame
394+
* only.
395+
*/
396+
const tabBuilds = (): boolean => !linksFor(wanted).missing.length
397+
381398
/** A package bigger than the parent saves: the browser is left to save it, and the way is said where it may not. */
382399
function tooBig(size: number): void {
383400
saying(`This .h5p is ${sized(size)}, more than the chat saves with one press. ${BY_HAND}`)
@@ -737,7 +754,20 @@ download.addEventListener('click', (event) => {
737754
}
738755
return fetchToKeep()
739756
}
740-
if (hostSaves === null || !kept) return
757+
if (!kept) return
758+
if (hostSaves === null) {
759+
// A tab of the page's own: the browser saves what its link names.
760+
if (!framed) return
761+
// Framed, with no parent that saves: the frame may drop the download with nothing said (#114).
762+
// A tab the parent opens builds the package again and saves it, where a tab can build it.
763+
if (hostOpens && tabBuilds()) {
764+
event.preventDefault()
765+
toParent({ type: 'open', href: savingLink() })
766+
return saying(`A new tab builds your .h5p and saves it. No tab? ${BY_HAND_TOO}`)
767+
}
768+
// Else the browser is left to try, and the way that works in any frame is said.
769+
return saying(`Nothing saved? ${BY_HAND_TOO}`)
770+
}
741771
if (kept.size > hostSaves) return tooBig(kept.size)
742772
event.preventDefault()
743773
if (!handed) handOver(kept)

0 commit comments

Comments
 (0)