Skip to content

Commit

Permalink
Move registration of receive-webshare
Browse files Browse the repository at this point in the history
  • Loading branch information
sungaila committed Nov 19, 2023
1 parent 8bd106c commit 79315ed
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/WebConverter/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,20 @@
<script>
window.setDotNetHelper = dotNetHelper => {
window.dotNetHelper = dotNetHelper;
}

navigator.serviceWorker.onmessage = async event => {
if (event.data?.type === 'receive-webshare') {
await window.dotNetHelper?.invokeMethodAsync('ReceiveWebShareTargetAsync', JSON.stringify(event.data.payload));
}
};

navigator.serviceWorker.ready
.then(registration => {
if (registration.active) {
registration.active.postMessage('receive-webshare');
navigator.serviceWorker.onmessage = async event => {
if (event.data?.type === 'receive-webshare') {
await window.dotNetHelper?.invokeMethodAsync('ReceiveWebShareTargetAsync', JSON.stringify(event.data.payload));
}
});
};

navigator.serviceWorker.ready
.then(registration => {
if (registration.active) {
registration.active.postMessage('receive-webshare');
}
});
}

window.createFileFromStream = async (fileName, mimeType, contentStreamReference) => {
const arrayBuffer = await contentStreamReference.arrayBuffer();
Expand Down

0 comments on commit 79315ed

Please sign in to comment.