mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-12 22:09:43 -04:00
Use messageChannelWaiting to detect UWP window
Former-commit-id: ee211cd54b2503e39aec84aa2345350371689e91 [formerly 29e283cc03d454f2cea3faaf33b3736d059eef15] [formerly 9d836745cb38e2df60f2eca3b64e13ee8a430986] [formerly 4811d9b6972f68f92d35d7ca4af3a578a2acfa63 [formerly cd972a11424f58778165ca84ac9d95021a669d47 [formerly 2dd6414288f9874ff8edf8d4c9171df50061c3e1]]] Former-commit-id: af3094015d78478b856b0d422ddfd7307f0df901 [formerly f7a357f69ffe4ae0a029ee3d33d746826a621cdd [formerly 493a9a4641b222f605ff1d8f1022c4f28e98b35e]] Former-commit-id: 0b20419078144d104d01e493907175258fbbeed1 [formerly e6f2367710abc2cbca440fbab7e53fdc9333856e] Former-commit-id: d0a69ce7927bd9919905efcc0c863451d418e682
This commit is contained in:
parent
f29ce8a505
commit
cfdcadfe0d
@ -3680,13 +3680,6 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
|
||||
} else {
|
||||
var mimetype = dirEntry.getMimetype();
|
||||
var imageDisplayMode = params.imageDisplayMode;
|
||||
// UWP apps with windows need to allow all images in all throughput
|
||||
if (/UWP/.test(params.appType) && (articleContainer.kiwixType === 'window' || appstate.messageChannelWaiting) &&
|
||||
params.imageDisplay) { imageDisplayMode = 'all'; }
|
||||
// We need to do the same for Gutenberg and PHET ZIMs
|
||||
if (/gutenberg|phet/i.test(appstate.selectedArchive._file.name)) {
|
||||
imageDisplayMode = 'all';
|
||||
}
|
||||
// console.debug('Spinner should show now: [' + mimetype + '] ' + title);
|
||||
if (/\b(css|javascript|video|vtt|webm)\b/i.test(mimetype)) {
|
||||
var shortTitle = dirEntry.url.replace(/[^/]+\//g, '').substring(0, 18);
|
||||
@ -3706,7 +3699,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
|
||||
// Tell the read routine that the request comes from a messageChannel
|
||||
appstate.messageChannelWaiting = true;
|
||||
readArticle(dirEntry);
|
||||
setTimeout(postTransformedHTML, 300, message, messagePort, dirEntry);
|
||||
setTimeout(postTransformedHTML, 400, message, messagePort, dirEntry);
|
||||
} else {
|
||||
postTransformedHTML(message, messagePort, dirEntry);
|
||||
}
|
||||
@ -3759,14 +3752,14 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
|
||||
|
||||
function postTransformedHTML(thisMessage, thisMessagePort, thisDirEntry) {
|
||||
if (params.transformedHTML && /<html[^>]*>/.test(params.transformedHTML)) {
|
||||
// // Because UWP app window can only be controlled from the Service Worker, we have to allow all images
|
||||
// // to be called from any external windows
|
||||
// if (/UWP/.test(params.appType) && (appstate.target === 'window' || appstate.messageChannelWaiting) &&
|
||||
// params.imageDisplay) { imageDisplayMode = 'all'; }
|
||||
// // We need to do the same for Gutenberg and PHET ZIMs
|
||||
// if (/gutenberg|phet/i.test(appstate.selectedArchive._file._files[0].name)) {
|
||||
// imageDisplayMode = 'all';
|
||||
// }
|
||||
// Because UWP app window can only be controlled from the Service Worker, we have to allow all images
|
||||
// to be called from any external windows. NB messageChannelWaiting is only true when user requested article from a window
|
||||
if (/UWP/.test(params.appType) && (appstate.target === 'window' || appstate.messageChannelWaiting) &&
|
||||
params.imageDisplay) { imageDisplayMode = 'all'; }
|
||||
// We need to do the same for Gutenberg and PHET ZIMs
|
||||
if (/gutenberg|phet/i.test(appstate.selectedArchive._file.name)) {
|
||||
imageDisplayMode = 'all';
|
||||
}
|
||||
appstate.messageChannelWaiting = false;
|
||||
// Let's send the content to the ServiceWorker
|
||||
thisMessage.content = params.transformedHTML;
|
||||
@ -3795,7 +3788,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
|
||||
}
|
||||
thisMessagePort.postMessage(thisMessage);
|
||||
} else {
|
||||
setTimeout(postTransformedHTML, 500, thisMessage, thisMessagePort, thisDirEntry);
|
||||
setTimeout(postTransformedHTML, 200, thisMessage, thisMessagePort, thisDirEntry);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user