bloby-bot 0.24.2 → 0.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/supervisor/index.ts +24 -3
package/package.json
CHANGED
package/supervisor/index.ts
CHANGED
|
@@ -555,7 +555,29 @@ ${connected
|
|
|
555
555
|
: '<p class="loading">Starting WhatsApp...</p>'}
|
|
556
556
|
</div>
|
|
557
557
|
${!connected ? `<script>
|
|
558
|
-
|
|
558
|
+
// Poll for status changes instead of full page reload (avoids SW reinstall cycle)
|
|
559
|
+
let polling=true;
|
|
560
|
+
async function poll(){
|
|
561
|
+
if(!polling) return;
|
|
562
|
+
try{
|
|
563
|
+
const [statusRes,qrRes]=await Promise.all([
|
|
564
|
+
fetch('/api/channels/status'),
|
|
565
|
+
fetch('/api/channels/whatsapp/qr')
|
|
566
|
+
]);
|
|
567
|
+
const statuses=await statusRes.json();
|
|
568
|
+
const qrData=await qrRes.json();
|
|
569
|
+
const wa=Array.isArray(statuses)?statuses.find(s=>s.channel==='whatsapp'):null;
|
|
570
|
+
if(wa?.connected){location.reload();return}
|
|
571
|
+
if(qrData.qr){
|
|
572
|
+
const inner=document.querySelector('.qr-inner');
|
|
573
|
+
if(inner) inner.innerHTML=qrData.qr;
|
|
574
|
+
const loading=document.querySelector('.loading');
|
|
575
|
+
if(loading) loading.remove();
|
|
576
|
+
}
|
|
577
|
+
}catch{}
|
|
578
|
+
setTimeout(poll,3000);
|
|
579
|
+
}
|
|
580
|
+
setTimeout(poll,3000);
|
|
559
581
|
|
|
560
582
|
function togglePhoneForm(){
|
|
561
583
|
document.getElementById('phoneForm').classList.toggle('visible');
|
|
@@ -585,8 +607,7 @@ ${!connected ? `<script>
|
|
|
585
607
|
const errEl=document.getElementById('codeError');
|
|
586
608
|
if(!document.getElementById('codeDisplay').classList.contains('visible')){
|
|
587
609
|
const hint=document.querySelector('.phone-hint');
|
|
588
|
-
if(hint)
|
|
589
|
-
hint.style.color='#FB4072';
|
|
610
|
+
if(hint){hint.textContent=err.message;hint.style.color='#FB4072'}
|
|
590
611
|
}else{
|
|
591
612
|
errEl.textContent=err.message;
|
|
592
613
|
}
|