Changed webWorker terminate images & attachemnts

This commit is contained in:
Justin Ferrari 2023-03-01 14:24:32 -05:00
parent 42e0200c33
commit 162148e8a6

View File

@ -3149,8 +3149,6 @@ class ChatPage extends LitElement {
// create new var called repliedToData and use that to modify the UI // create new var called repliedToData and use that to modify the UI
// find specific object property in local // find specific object property in local
let typeMessage = 'regular'; let typeMessage = 'regular';
let workerImage;
let workerAttachment;
this.isLoading = true; this.isLoading = true;
const trimmedMessage = msg const trimmedMessage = msg
@ -3180,11 +3178,12 @@ class ChatPage extends LitElement {
var str = "iVBORw0KGgoAAAANSUhEUgAAAsAAAAGMAQMAAADuk4YmAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAADlJREFUeF7twDEBAAAAwiD7p7bGDlgYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAGJrAABgPqdWQAAAABJRU5ErkJggg=="; var str = "iVBORw0KGgoAAAANSUhEUgAAAsAAAAGMAQMAAADuk4YmAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAADlJREFUeF7twDEBAAAAwiD7p7bGDlgYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAGJrAABgPqdWQAAAABJRU5ErkJggg==";
if (this.webWorkerFile) { if (this.webWorkerFile) {
workerImage = this.webWorkerFile; this.webWorkerFile.terminate();
} else { this.webWorkerFile = null;
this.webWorkerFile = new WebWorkerFile();
} }
this.webWorkerFile = new WebWorkerFile();
const b64toBlob = (b64Data, contentType='', sliceSize=512) => { const b64toBlob = (b64Data, contentType='', sliceSize=512) => {
const byteCharacters = atob(b64Data); const byteCharacters = atob(b64Data);
const byteArrays = []; const byteArrays = [];
@ -3232,7 +3231,7 @@ class ChatPage extends LitElement {
metaData: undefined, metaData: undefined,
uploadType: 'file', uploadType: 'file',
selectedAddress: this.selectedAddress, selectedAddress: this.selectedAddress,
worker: workerImage worker: this.webWorkerFile
}) })
this.isDeletingImage = false this.isDeletingImage = false
} catch (error) { } catch (error) {
@ -3268,11 +3267,12 @@ class ChatPage extends LitElement {
const identifier = outSideMsg.identifier; const identifier = outSideMsg.identifier;
if (this.webWorkerFile) { if (this.webWorkerFile) {
workerAttachment = this.webWorkerFile; this.webWorkerFile.terminate();
} else { this.webWorkerFile = null;
this.webWorkerFile = new WebWorkerFile();
} }
this.webWorkerFile = new WebWorkerFile();
const b64toBlob = (b64Data, contentType='', sliceSize=512) => { const b64toBlob = (b64Data, contentType='', sliceSize=512) => {
const byteCharacters = atob(b64Data); const byteCharacters = atob(b64Data);
const byteArrays = []; const byteArrays = [];
@ -3322,7 +3322,7 @@ class ChatPage extends LitElement {
metaData: undefined, metaData: undefined,
uploadType: 'file', uploadType: 'file',
selectedAddress: this.selectedAddress, selectedAddress: this.selectedAddress,
worker: workerAttachment worker: this.webWorkerFile
}) })
this.isDeletingAttachment = false this.isDeletingAttachment = false
} catch (error) { } catch (error) {
@ -3362,11 +3362,12 @@ class ChatPage extends LitElement {
} }
if (this.webWorkerFile) { if (this.webWorkerFile) {
workerImage = this.webWorkerFile; this.webWorkerFile.terminate();
} else { this.webWorkerFile = null;
this.webWorkerFile = new WebWorkerFile();
} }
this.webWorkerFile = new WebWorkerFile();
const image = this.imageFile const image = this.imageFile
const id = this.uid(); const id = this.uid();
const identifier = `qchat_${id}`; const identifier = `qchat_${id}`;
@ -3404,7 +3405,7 @@ class ChatPage extends LitElement {
metaData: undefined, metaData: undefined,
uploadType: 'file', uploadType: 'file',
selectedAddress: this.selectedAddress, selectedAddress: this.selectedAddress,
worker: workerImage worker: this.webWorkerFile
}); });
this.isUploadingImage = false; this.isUploadingImage = false;
this.removeImage(); this.removeImage();
@ -3459,11 +3460,13 @@ class ChatPage extends LitElement {
} }
if (this.webWorkerFile) { if (this.webWorkerFile) {
workerAttachment = this.webWorkerFile; this.webWorkerFile.terminate();
} else { this.webWorkerFile = null;
this.webWorkerFile = new WebWorkerFile();
} }
this.webWorkerFile = new WebWorkerFile();
const attachment = this.attachment; const attachment = this.attachment;
const id = this.uid(); const id = this.uid();
const identifier = `qchat_${id}`; const identifier = `qchat_${id}`;
@ -3484,7 +3487,7 @@ class ChatPage extends LitElement {
metaData: undefined, metaData: undefined,
uploadType: 'file', uploadType: 'file',
selectedAddress: this.selectedAddress, selectedAddress: this.selectedAddress,
worker: workerAttachment worker: this.webWorkerFile
}); });
this.isUploadingAttachment = false; this.isUploadingAttachment = false;
this.removeAttachment(); this.removeAttachment();