From d9762007afa8442fe7b64f5663501bfa69814434 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Tue, 23 Jan 2024 17:27:06 -0800 Subject: [PATCH] fix: Don't connect when there is no token (#30) * fix: Don't connect when there is no token * fix: Don't connect when there is no token --- public/full.js | 8 ++++++-- public/minimal.js | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/public/full.js b/public/full.js index 3d97887..aafee5b 100644 --- a/public/full.js +++ b/public/full.js @@ -350,7 +350,7 @@ function restoreUI() { } async function getClient() { - if (!client) { + if (!client && _token) { client = await SWire({ host: _host, token: _token, @@ -365,6 +365,8 @@ async function getClient() { * Connect with Relay creating a client and attaching all the event handler. */ window.connect = async () => { + if (!_token) return + const client = await getClient() window.__client = client @@ -854,7 +856,9 @@ window.seekForwardPlayback = () => { window.ready(async function () { console.log('Ready!') const client = await getClient() - await client.connect() + if (client) { + await client.connect() + } const searchParams = new URLSearchParams(location.search) console.log('Handle inbound?', searchParams.has('inbound')) if (searchParams.has('inbound')) { diff --git a/public/minimal.js b/public/minimal.js index 9692968..20ac2cd 100644 --- a/public/minimal.js +++ b/public/minimal.js @@ -16,6 +16,8 @@ window.ready = (callback) => { } async function connect() { + if (!_token) return + client = await SignalWire.SignalWire({ host: _host, token: _token,