Consistent spelling of canceled

This commit is contained in:
David Baker 2019-04-08 19:07:17 +01:00
parent 59210564b7
commit 3ad54df454

View file

@ -34,7 +34,7 @@ import "blueimp-canvas-to-blob";
const MAX_WIDTH = 800; const MAX_WIDTH = 800;
const MAX_HEIGHT = 600; const MAX_HEIGHT = 600;
export class UploadCancelledError extends Error {} export class UploadCanceledError extends Error {}
/** /**
* Create a thumbnail for a image DOM element. * Create a thumbnail for a image DOM element.
@ -237,15 +237,15 @@ function uploadFile(matrixClient, roomId, file, progressHandler) {
if (matrixClient.isRoomEncrypted(roomId)) { if (matrixClient.isRoomEncrypted(roomId)) {
// If the room is encrypted then encrypt the file before uploading it. // If the room is encrypted then encrypt the file before uploading it.
// First read the file into memory. // First read the file into memory.
let cancelled = false; let canceled = false;
let uploadPromise; let uploadPromise;
let encryptInfo; let encryptInfo;
const prom = readFileAsArrayBuffer(file).then(function(data) { const prom = readFileAsArrayBuffer(file).then(function(data) {
if (cancelled) throw new UploadCancelledError(); if (canceled) throw new UploadCanceledError();
// Then encrypt the file. // Then encrypt the file.
return encrypt.encryptAttachment(data); return encrypt.encryptAttachment(data);
}).then(function(encryptResult) { }).then(function(encryptResult) {
if (cancelled) throw new UploadCancelledError(); if (canceled) throw new UploadCanceledError();
// Record the information needed to decrypt the attachment. // Record the information needed to decrypt the attachment.
encryptInfo = encryptResult.info; encryptInfo = encryptResult.info;
// Pass the encrypted data as a Blob to the uploader. // Pass the encrypted data as a Blob to the uploader.
@ -267,7 +267,7 @@ function uploadFile(matrixClient, roomId, file, progressHandler) {
return {"file": encryptInfo}; return {"file": encryptInfo};
}); });
prom.abort = () => { prom.abort = () => {
cancelled = true; canceled = true;
if (uploadPromise) MatrixClientPeg.get().cancelUpload(uploadPromise); if (uploadPromise) MatrixClientPeg.get().cancelUpload(uploadPromise);
}; };
return prom; return prom;