From 5b09df0a0a1682e20037bb6eb288aca6b3029087 Mon Sep 17 00:00:00 2001 From: Extremesecrecy <10959169+extremesecrecy@users.noreply.github.com> Date: Fri, 25 Jul 2025 12:52:58 -0700 Subject: [PATCH] Update PiPedalModel.tsx vite/src/pipedal/PiPedalModel.tsx - For this file only! Expected outcome is that the server may (or may not) reboot). The purpose of the catch handler (which would happen in the case of a socket disconnect) is to make sure that an error or abort does not get reported, since it is expected. Changes to wifi configuration, where the handler code MUST NOT PROPAGATE AN EXCEPTION. (1) just leave this function to rot in its shameful state of decay, but do NOT relay the error. (2) Write the audio properties (specifically) without waiting for a response. The settings are propagated to other clients (and ourselves) with a on...changed notifications from the server, so there's no actual response from the server required. Audio properties specified: const audioProps = [ "http://two-play.com/plugins/toob-player#audioFile", "http://two-play.com/plugins/toob-player#loop", "http://two-play.com/plugins/toob-player#seek", ]; --- vite/src/pipedal/PiPedalModel.tsx | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/vite/src/pipedal/PiPedalModel.tsx b/vite/src/pipedal/PiPedalModel.tsx index 1c4db09..4d4d64e 100644 --- a/vite/src/pipedal/PiPedalModel.tsx +++ b/vite/src/pipedal/PiPedalModel.tsx @@ -2343,6 +2343,22 @@ export class PiPedalModel //implements PiPedalModel } } setPatchProperty(instanceId: number, uri: string, value: any): Promise { + // Audio related properties are written without waiting for a reply. + // These URIs correspond to Toob player audio state. The server + // broadcasts changes via on...changed messages, so we don't + // need to wait for the reply when updating them. + const audioProps = [ + "http://two-play.com/plugins/toob-player#audioFile", + "http://two-play.com/plugins/toob-player#loop", + "http://two-play.com/plugins/toob-player#seek", + ]; + if (audioProps.indexOf(uri) >= 0) { + if (this.webSocket) { + this.webSocket.send("setPatchProperty", { instanceId: instanceId, propertyUri: uri, value: value }); + } + return Promise.resolve(true); + } + let result = new Promise((resolve, reject) => { if (this.webSocket) { this.webSocket.request( @@ -2983,7 +2999,7 @@ export class PiPedalModel //implements PiPedalModel // notify the server. let ws = this.webSocket; if (!ws) { - reject("Not connected."); + resolve(); return; } ws.request( @@ -2994,7 +3010,8 @@ export class PiPedalModel //implements PiPedalModel resolve(); }) .catch((err) => { - reject(err); + // ignore expected disconnects/errors + resolve(); }); }); @@ -3049,7 +3066,8 @@ export class PiPedalModel //implements PiPedalModel resolve(); }) .catch((err) => { - reject(err); + // ignore expected disconnects/errors + resolve(); }); //resolve();