show transparent image when nothing loaded

This commit is contained in:
Lewis Moten
2024-05-17 17:55:09 -04:00
parent 0ab31040f7
commit 20406a9e72
2 changed files with 7 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
import { bytesToText, bytesToUrl } from '../converters.js'; import { bytesToText, bytesToUrl } from '../converters.js';
import BasePanel from './BasePanel.js'; import BasePanel from './BasePanel.js';
import * as AudioReceiver from '../AudioReceiver.js'; import * as AudioReceiver from '../AudioReceiver.js';
const NO_IMAGE = 'transparent.png';
class ReceivePanel extends BasePanel { class ReceivePanel extends BasePanel {
constructor() { constructor() {
super('Audio Receiver'); super('Audio Receiver');
@@ -17,7 +17,7 @@ class ReceivePanel extends BasePanel {
this.addProgressBar('progress', 0, 0); this.addProgressBar('progress', 0, 0);
this.addCode('text', '', 'small'); this.addCode('text', '', 'small');
this.addImage('image', undefined, {width: 32, height: 32}); this.addImage('image', NO_IMAGE, {width: 32, height: 32});
this.setDataType('text'); this.setDataType('text');
this.dispatcher.addListener('onlineChange', (e) => { this.dispatcher.addListener('onlineChange', (e) => {
@@ -64,11 +64,14 @@ class ReceivePanel extends BasePanel {
} }
setReceivedHtml = (html) => this.setHtmlById('text', html); setReceivedHtml = (html) => this.setHtmlById('text', html);
setReceivedBytes = bytes => { setReceivedBytes = bytes => {
console.log('received', bytes);
if(this.dataType === 'text') { if(this.dataType === 'text') {
this.setValueById('text', bytesToText(bytes)); this.setValueById('text', bytesToText(bytes));
} else { } else {
this.setValueById('image', bytesToUrl(bytes)); if(bytes !== undefined && bytes.length > 0) {
this.setValueById('image', bytesToUrl(bytes));
} else {
this.setValueById('image', NO_IMAGE);
}
} }
} }

BIN
transparent.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B