diff options
| author | metamuffin <metamuffin@disroot.org> | 2023-05-27 13:47:56 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2023-05-27 13:47:56 +0200 | 
| commit | ab1c3b39a1077b3f4bad75c6a0722c850d06d409 (patch) | |
| tree | bddfff3e47c8f5559c60d0346492f1917c9b9f25 /client-web/source/resource | |
| parent | adb6d2425997841b51d9989e0a5a268810742e71 (diff) | |
| download | keks-meet-ab1c3b39a1077b3f4bad75c6a0722c850d06d409.tar keks-meet-ab1c3b39a1077b3f4bad75c6a0722c850d06d409.tar.bz2 keks-meet-ab1c3b39a1077b3f4bad75c6a0722c850d06d409.tar.zst | |
handle dc on_message ArrayBuffer as well to work in chromium
Diffstat (limited to 'client-web/source/resource')
| -rw-r--r-- | client-web/source/resource/file.ts | 15 | 
1 files changed, 11 insertions, 4 deletions
| diff --git a/client-web/source/resource/file.ts b/client-web/source/resource/file.ts index f577580..738473a 100644 --- a/client-web/source/resource/file.ts +++ b/client-web/source/resource/file.ts @@ -77,13 +77,21 @@ export const resource_file: ResourceHandlerDecl = {                      reset()                  }                  channel.onmessage = ev => { -                    const data: Blob | string = ev.data +                    const data: Blob | ArrayBuffer | string = ev.data +                    console.log(data);                      if (typeof data == "string") {                          if (data == "end") {                              finished = true +                            channel.close()                          } -                    } else { -                        download.write(data as Blob) +                    } else if (data instanceof Blob) { +                        const reader = new FileReader(); +                        reader.onload = function (event) { +                            download.write(event.target!.result as ArrayBuffer) +                        }; +                        reader.readAsArrayBuffer(data); +                    } else if (data instanceof ArrayBuffer) { +                        download.write(data)                      }                  }              } @@ -135,7 +143,6 @@ function file_res_inner(file: File): LocalResource {                      await sleep(10)                  }                  display.status = "Waiting for the channel to close…" -                channel.close()              }              const feed = async () => {                  const { value: chunk, done }: { value?: Uint8Array, done: boolean } = await reader.read() | 
