luc-github / ESP3D-WEBUI

A Web UI for ESP8266 or ESP32 based boards connected to 3D printers / CNC
GNU General Public License v3.0
733 stars 304 forks source link

Added noToast field for "cmd" extension messages #393

Closed MitchBradley closed 2 weeks ago

MitchBradley commented 2 weeks ago

If eventMsg.data contains ".noToast" with a true value and the command results in an error, the error message toast will be suppressed. That lets the extension handle errors internally without the user seeing a possibly-confusing message.

One use case is when the extension needs to issue a command that might not exist in older versions of the controller firmware, handling the error quietly for backwards compatibility.

MitchBradley commented 2 weeks ago

Here is an example of how an extension might use the feature:

window.parent.postMessage({type:'cmd', target:'webui', id:'axis', content:'$9999', noToast:true}, '*');

If the command "$9999" does not exist, the extension can handle the error quietly in its message handler, possibly falling back to a different approach that works on older controller firmware that does not implement $9999.

luc-github commented 2 weeks ago

this is no need - I have removed the auto toast in extension API because it is extension to control if need a toast or not and what should be the message in it

MitchBradley commented 2 weeks ago

Excellent, thanks.