bloby-bot 0.24.2 → 0.24.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bloby-bot",
3
- "version": "0.24.2",
3
+ "version": "0.24.4",
4
4
  "releaseNotes": [
5
5
  "1. new stuff",
6
6
  "2. ",
@@ -29,11 +29,17 @@ function formatTime(iso: string): string {
29
29
  }
30
30
  }
31
31
 
32
- /** Convert backtick-wrapped WhatsApp QR URL into a markdown link */
32
+ /** Convert WhatsApp QR URL (any format) into a markdown link so the button renders */
33
33
  function preprocessContent(text: string): string {
34
+ const link = '[pair-whatsapp](/api/channels/whatsapp/qr-page)';
35
+ // Already a properly formatted markdown link — skip
36
+ if (text.includes(link)) return text;
37
+ // Backtick-wrapped full URL: `http://localhost:7400/api/channels/whatsapp/qr-page`
38
+ // Full URL in plain text: http://localhost:7400/api/channels/whatsapp/qr-page
39
+ // Bare relative path: /api/channels/whatsapp/qr-page
34
40
  return text.replace(
35
- /`http:\/\/localhost:\d+\/api\/channels\/whatsapp\/qr-page`/g,
36
- '[pair-whatsapp](/api/channels/whatsapp/qr-page)'
41
+ /`?(?:http:\/\/localhost:\d+)?\/api\/channels\/whatsapp\/qr-page`?/g,
42
+ link,
37
43
  );
38
44
  }
39
45
 
@@ -555,7 +555,29 @@ ${connected
555
555
  : '<p class="loading">Starting WhatsApp...</p>'}
556
556
  </div>
557
557
  ${!connected ? `<script>
558
- setTimeout(()=>location.reload(),4000);
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) hint.textContent=err.message;
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
  }