mirror of
https://gitlab.com/timvisee/send.git
synced 2025-12-09 11:45:36 +00:00
more frontend tests and some factoring based on them
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user