Moves DraftAttachments into redux
This commit is contained in:
parent
f81f61af4e
commit
1c3c971cf4
20 changed files with 818 additions and 444 deletions
18
ts/util/fileToBytes.ts
Normal file
18
ts/util/fileToBytes.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export function fileToBytes(file: Blob): Promise<Uint8Array> {
|
||||
return new Promise((resolve, rejectPromise) => {
|
||||
const FR = new FileReader();
|
||||
FR.onload = () => {
|
||||
if (!FR.result || typeof FR.result === 'string') {
|
||||
rejectPromise(new Error('bytesFromFile: No result!'));
|
||||
return;
|
||||
}
|
||||
resolve(new Uint8Array(FR.result));
|
||||
};
|
||||
FR.onerror = rejectPromise;
|
||||
FR.onabort = rejectPromise;
|
||||
FR.readAsArrayBuffer(file);
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue