more frontend tests and some factoring based on them
This commit is contained in:
parent
78728ce4ca
commit
d6c0489fa3
6 changed files with 153 additions and 107 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue