From c9b96f048803e3e95dd6800a8485d11ef6eeab14 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Tue, 16 Jan 2024 17:27:27 +0900 Subject: [PATCH] fix(tuna-obs): partially fix #1596 --- src/plugins/tuna-obs/index.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/plugins/tuna-obs/index.ts b/src/plugins/tuna-obs/index.ts index 40cc247b71..fae1c64163 100644 --- a/src/plugins/tuna-obs/index.ts +++ b/src/plugins/tuna-obs/index.ts @@ -26,6 +26,7 @@ export default createPlugin({ enabled: false, }, backend: { + liteMode: false, data: { cover: '', cover_url: '', @@ -51,18 +52,28 @@ export default createPlugin({ const url = `http://127.0.0.1:${port}/`; net .fetch(url, { - method: 'POST', + method: this.liteMode ? 'OPTIONS' : 'POST', headers, keepalive: true, - body: JSON.stringify({ data }), + body: this.liteMode ? undefined : JSON.stringify({ data }), + }) + .then(() => { + if (this.liteMode) { + this.liteMode = false; + console.debug( + `obs-tuna webserver at port ${port} is now accessible. disable lite mode`, + ); + post(data); + } }) .catch((error: { code: number; errno: number }) => { - if (is.dev()) { + if (!this.liteMode && is.dev()) { console.debug( `Error: '${ error.code || error.errno - }' - when trying to access obs-tuna webserver at port ${port}`, + }' - when trying to access obs-tuna webserver at port ${port}. enable lite mode`, ); + this.liteMode = true; } }); };