From 20406a9e728ebbd65a985e32715a4111273e0eac Mon Sep 17 00:00:00 2001 From: Lewis Moten Date: Fri, 17 May 2024 17:55:09 -0400 Subject: [PATCH] show transparent image when nothing loaded --- Panels/ReceivePanel.js | 11 +++++++---- transparent.png | Bin 0 -> 68 bytes 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 transparent.png diff --git a/Panels/ReceivePanel.js b/Panels/ReceivePanel.js index 9a0249d..0d0fdf0 100644 --- a/Panels/ReceivePanel.js +++ b/Panels/ReceivePanel.js @@ -1,7 +1,7 @@ import { bytesToText, bytesToUrl } from '../converters.js'; import BasePanel from './BasePanel.js'; import * as AudioReceiver from '../AudioReceiver.js'; - +const NO_IMAGE = 'transparent.png'; class ReceivePanel extends BasePanel { constructor() { super('Audio Receiver'); @@ -17,7 +17,7 @@ class ReceivePanel extends BasePanel { this.addProgressBar('progress', 0, 0); 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.dispatcher.addListener('onlineChange', (e) => { @@ -64,11 +64,14 @@ class ReceivePanel extends BasePanel { } setReceivedHtml = (html) => this.setHtmlById('text', html); setReceivedBytes = bytes => { - console.log('received', bytes); if(this.dataType === 'text') { this.setValueById('text', bytesToText(bytes)); } else { - this.setValueById('image', bytesToUrl(bytes)); + if(bytes !== undefined && bytes.length > 0) { + this.setValueById('image', bytesToUrl(bytes)); + } else { + this.setValueById('image', NO_IMAGE); + } } } diff --git a/transparent.png b/transparent.png new file mode 100644 index 0000000000000000000000000000000000000000..af367b99a00dc1613aaba25466ded4b74e58d0ed GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k8}blZci7-5RU7~2@FgO46F={kJMOa Q1BDqpUHx3vIVCg!09!{3-~a#s literal 0 HcmV?d00001