more frontend tests and some factoring based on them

This commit is contained in:
Danny Coates 2018-02-24 11:24:12 -08:00
parent 78728ce4ca
commit d6c0489fa3
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
6 changed files with 153 additions and 107 deletions

View file

@ -9,11 +9,8 @@ export default class FileSender extends Nanobus {
constructor(file) {
super('FileSender');
this.file = file;
this.uploadRequest = null;
this.msg = 'importingFile';
this.progress = [0, 1];
this.cancelled = false;
this.keychain = new Keychain();
this.reset();
}
get progressRatio() {
@ -31,6 +28,13 @@ export default class FileSender extends Nanobus {
};
}
reset() {
this.uploadRequest = null;
this.msg = 'importingFile';
this.progress = [0, 1];
this.cancelled = false;
}
cancel() {
this.cancelled = true;
if (this.uploadRequest) {
@ -71,13 +75,13 @@ export default class FileSender extends Nanobus {
encrypted,
metadata,
authKeyB64,
this.keychain
this.keychain,
p => {
this.progress = p;
this.emit('progress', p);
}
);
this.msg = 'fileSizeProgress';
this.uploadRequest.onprogress = p => {
this.progress = p;
this.emit('progress', p);
};
try {
const result = await this.uploadRequest.result;
const time = Date.now() - start;