livechat 1.2.0 → 1.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 771d11b3c4a9a70c254bbe8f403fe4196f1aff26395fd31d023638b261fcea50
4
- data.tar.gz: cc8ef5bf1ef7dc04f66eff71481297782ea8496ada69f7bc48cab57fe3e5bfca
3
+ metadata.gz: d7fa5188b3a4e41efad9925ecc22275862474505bc2696355b2977c7ecb7ba71
4
+ data.tar.gz: 6759505e2ccc14288b08227e050a3e7a13057193e3ed4551c1722f309a22fd2f
5
5
  SHA512:
6
- metadata.gz: 4e9dcd6248961f6785a85fb77c79d3fbc7c5a4d79871ef7cffc7b137615c81467f77aeab2354475fd1f69ed9233ab4759eec426a52ad1aaf14cb009527e4bd0b
7
- data.tar.gz: a214328cf56cede8a3179256e30e7fc9756d4e725d69001bc396c2d0343b2beb911f0644866f6b0bf74cad4ddba026f0b0bc83f7b901ab8f96960e7106e78d6f
6
+ metadata.gz: 58d2d11a943b96a323d40b92e76e0ad1082231c9a8643559e53f15605e104311498d4a9630b691192759c0a26a4eab6acb9dabeee28604a5f2073918a9938ce7
7
+ data.tar.gz: 64b85177dbece4ac7a7a728ff45c1c8297d646f211471fbabd1a6d9367aab5b1bdf8dc28ace34423959d8423cf04919c52a8daa2a38907fd0a366620f83bb4f0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0 - 2026-11-14
4
+
5
+ - Add `data-livechat-badge-class` to `data-livechat-open` elements. The unread
6
+ badge on that opener gets the host's classes and none of the built-in style,
7
+ so a Tailwind or daisyUI app can use its own badge without overriding ours.
8
+ The built-in style is injected outside any cascade layer, so before this a
9
+ host had to outrank it with a more specific selector of its own. Openers
10
+ without the attribute look and behave as before.
11
+
12
+ ## 1.2.2 - 2026-10-18
13
+
14
+ - Clarify the widget's resolved message in all 26 locales: visitors can send
15
+ another message whenever they need help. Follow-ups keep the same thread
16
+ and history; different questions still share one open/resolved status.
17
+ The longer guidance can wrap across more than one line in the timeline.
18
+
19
+ ## 1.2.1 - 2026-10-18
20
+
21
+ - Bind the inbox status form's CSRF token to the actual resolve or reopen
22
+ destination. Status changes and replies use local forms so older host apps
23
+ do not require Rails UJS to supply their tokens; CSRF checks stay enabled.
24
+ - Return focus to the agent composer after a reply, including Ctrl/Cmd+Enter
25
+ in the split-pane inbox. One form-destination marker is kept in per-tab
26
+ session storage for the next navigation; message bodies are not stored.
27
+ Ordinary inbox visits keep their existing focus behavior.
28
+
3
29
  ## 1.2.0 - 2026-10-18
4
30
 
5
31
  - Add Rails edge CI and experimental Ruby 4.0+ Ractor request support. The host
data/README.md CHANGED
@@ -96,6 +96,11 @@ the things it should not do. It ships inside the gem, so
96
96
  resolve it when done. A visitor writing again reopens it.
97
97
  4. The visitor sees the reply in the widget, or by email when they're gone.
98
98
 
99
+ Each visitor has one ongoing conversation. Resolving it marks the current
100
+ exchange as handled; the visitor can send another message at any time to
101
+ reopen that same thread, with the history intact. Different questions share
102
+ one open/resolved status.
103
+
99
104
  **Realtime is polling, on purpose:** ~4s while the panel is open, ~30s in the
100
105
  background, nothing at all for visitors who never wrote. No Action Cable, no
101
106
  Redis, no infrastructure. At support-chat volume you will not notice; your ops
@@ -367,6 +372,7 @@ to a stream the server signed for it. Under a strict CSP, allow the socket with
367
372
  | `window.Livechat.open()` / `.close()` | `open("Hi, I need help with…")` prefills the box — never over a visitor's draft |
368
373
  | `data-livechat-open` | Any element opens the panel on click |
369
374
  | `data-livechat-message="…"` | Prefill from that element — great for contextual buttons |
375
+ | `data-livechat-badge-class="…"` | Classes for that element's unread badge, in place of the built-in style |
370
376
  | `<%= livechat_button %>` | A plain, unstyled opener button |
371
377
  | `<%= livechat_button("Ask about this order", message: "I need help with order ##{@order.id}") %>` | Open and prefill in one helper |
372
378
  | `config.show_launcher = false` | Hide the bubble entirely |
@@ -374,6 +380,15 @@ to a stream the server signed for it. Under a strict CSP, allow the socket with
374
380
  While replies are unread, every `data-livechat-open` element carries a small
375
381
  count badge — so hiding the launcher never hides the answer.
376
382
 
383
+ The badge has a plain red style of its own. To match your design system, name
384
+ your own classes on the opener; the built-in style then steps aside:
385
+
386
+ ```erb
387
+ <button data-livechat-open data-livechat-badge-class="badge badge-error badge-xs ms-auto">
388
+ Contact support
389
+ </button>
390
+ ```
391
+
377
392
  Contextual buttons are where a Rails app beats a generic support widget:
378
393
 
379
394
  ```erb
@@ -465,6 +480,10 @@ the same host hooks (`base_controller_class` to inherit your admin's controller,
465
480
  two-pane layout, colour tokens and components in all five, scoped so it cannot
466
481
  touch your own CSS — and migrations that follow your app's `primary_key_type`.
467
482
 
483
+ ## Affiliation
484
+
485
+ An independent open-source Rails engine. Not affiliated with or endorsed by the company behind livechat.com.
486
+
468
487
  ## License
469
488
 
470
489
  MIT.
@@ -13,18 +13,19 @@
13
13
  </p>
14
14
  </div>
15
15
  <%# The shared status switch: the state it is in is lit and inert, the other
16
- one submits to its own route via `formaction`. One form, no JS, and
17
- clicking the lit half cannot log a reopen of an already-open chat. %>
18
- <%= form_with url: resolve_conversation_path(conversation), method: :post, class: 'status-switch' do %>
16
+ one submits to its own route. The form action must match that route
17
+ so Rails binds its per-form CSRF token to the actual submission. %>
18
+ <% status_path = conversation.open? ? resolve_conversation_path(conversation) : reopen_conversation_path(conversation) %>
19
+ <%= form_with url: status_path, method: :post, local: true, class: 'status-switch' do %>
19
20
  <% if conversation.open? %>
20
21
  <button type="button" class="status-open current" aria-current="true">
21
22
  <%= t('livechat.statuses.open', default: 'Open') %>
22
23
  </button>
23
- <button formaction="<%= resolve_conversation_path(conversation) %>" class="status-resolved">
24
+ <button type="submit" class="status-resolved">
24
25
  <%= t('livechat.statuses.resolved', default: 'Resolved') %>
25
26
  </button>
26
27
  <% else %>
27
- <button formaction="<%= reopen_conversation_path(conversation) %>" class="status-open">
28
+ <button type="submit" class="status-open">
28
29
  <%= t('livechat.statuses.open', default: 'Open') %>
29
30
  </button>
30
31
  <button type="button" class="status-resolved current" aria-current="true">
@@ -70,7 +71,7 @@
70
71
  <%# One bordered composer box (matches the visitor widget): the reply on top,
71
72
  a toolbar row below with tools on the left and send on the right. %>
72
73
  <%= form_with url: conversation_messages_path(conversation), method: :post,
73
- multipart: true, class: 'reply',
74
+ multipart: true, local: true, class: 'reply',
74
75
  data: {
75
76
  record_audio: t('livechat.dashboard.record_audio', default: 'Record audio'),
76
77
  stop_recording: t('livechat.dashboard.stop_recording', default: 'Stop recording'),
@@ -12,7 +12,7 @@ ar:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "حفظ"
14
14
  email_saved: "سنرد أيضًا عبر البريد الإلكتروني."
15
- event_resolved: "تم حل المحادثة"
15
+ event_resolved: "تم الحل حاليًا. أرسل رسالة أخرى متى احتجت إلى مساعدة."
16
16
  event_reopened: "تمت إعادة فتح المحادثة"
17
17
  error_send: "تعذر الإرسال. يرجى المحاولة مرة أخرى."
18
18
  error_rate_limited: "رسائل كثيرة جدًا. يرجى الانتظار قليلًا والمحاولة مرة أخرى."
@@ -12,7 +12,7 @@ bg:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "Запази"
14
14
  email_saved: "Ще отговорим и по имейл."
15
- event_resolved: "Разговорът е разрешен"
15
+ event_resolved: "Засега въпросът е решен. Изпратете ново съобщение, когато имате нужда от помощ."
16
16
  event_reopened: "Разговорът е отворен отново"
17
17
  error_send: "Изпращането не бе успешно. Моля, опитайте отново."
18
18
  error_rate_limited: "Твърде много съобщения. Моля, изчакайте малко и опитайте отново."
@@ -12,7 +12,7 @@ bn:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "সংরক্ষণ করুন"
14
14
  email_saved: "আমরা ইমেইলেও উত্তর দেব।"
15
- event_resolved: "কথোপকথন সমাধান হয়েছে"
15
+ event_resolved: "আপাতত সমাধান হয়েছে। সাহায্যের প্রয়োজন হলে আবার বার্তা পাঠান।"
16
16
  event_reopened: "কথোপকথন আবার খোলা হয়েছে"
17
17
  error_send: "পাঠানো যায়নি। অনুগ্রহ করে আবার চেষ্টা করুন।"
18
18
  error_rate_limited: "অনেক বেশি বার্তা। একটু অপেক্ষা করে আবার চেষ্টা করুন।"
@@ -12,7 +12,7 @@ de:
12
12
  email_placeholder: "sie@beispiel.de"
13
13
  email_save: "Speichern"
14
14
  email_saved: "Wir antworten auch per E-Mail."
15
- event_resolved: "Unterhaltung gelöst"
15
+ event_resolved: "Vorerst erledigt. Schreib uns jederzeit wieder, wenn du Hilfe brauchst."
16
16
  event_reopened: "Unterhaltung wieder geöffnet"
17
17
  error_send: "Senden fehlgeschlagen. Bitte versuchen Sie es erneut."
18
18
  error_rate_limited: "Zu viele Nachrichten. Bitte warten Sie einen Moment und versuchen Sie es erneut."
@@ -12,7 +12,7 @@ el:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "Αποθήκευση"
14
14
  email_saved: "Θα απαντήσουμε επίσης μέσω email."
15
- event_resolved: "Η συνομιλία επιλύθηκε"
15
+ event_resolved: "Το θέμα λύθηκε προς το παρόν. Στείλτε νέο μήνυμα όποτε χρειαστείτε βοήθεια."
16
16
  event_reopened: "Η συνομιλία άνοιξε ξανά"
17
17
  error_send: "Δεν ήταν δυνατή η αποστολή. Δοκιμάστε ξανά."
18
18
  error_rate_limited: "Πάρα πολλά μηνύματα. Περιμένετε λίγο και δοκιμάστε ξανά."
@@ -12,7 +12,7 @@ en:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "Save"
14
14
  email_saved: "We will also reply by email."
15
- event_resolved: "Conversation resolved"
15
+ event_resolved: "Resolved for now. Send another message whenever you need help."
16
16
  event_reopened: "Conversation reopened"
17
17
  error_send: "Could not send. Please try again."
18
18
  error_rate_limited: "Too many messages. Please wait a moment and try again."
@@ -12,7 +12,7 @@ es:
12
12
  email_placeholder: "tu@ejemplo.com"
13
13
  email_save: "Guardar"
14
14
  email_saved: "También te responderemos por correo."
15
- event_resolved: "Conversación resuelta"
15
+ event_resolved: "Resuelto por ahora. Envía otro mensaje cuando necesites ayuda."
16
16
  event_reopened: "Conversación reabierta"
17
17
  error_send: "No se pudo enviar. Inténtalo de nuevo."
18
18
  error_rate_limited: "Demasiados mensajes. Espera un momento e inténtalo de nuevo."
@@ -12,7 +12,7 @@ fr:
12
12
  email_placeholder: "vous@exemple.fr"
13
13
  email_save: "Enregistrer"
14
14
  email_saved: "Nous répondrons également par e-mail."
15
- event_resolved: "Conversation résolue"
15
+ event_resolved: "Résolu pour le moment. Envoyez un autre message dès que vous avez besoin d’aide."
16
16
  event_reopened: "Conversation rouverte"
17
17
  error_send: "Échec de l'envoi. Veuillez réessayer."
18
18
  error_rate_limited: "Trop de messages. Veuillez patienter un instant et réessayer."
@@ -12,7 +12,7 @@ hi:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "सहेजें"
14
14
  email_saved: "हम ईमेल से भी जवाब देंगे।"
15
- event_resolved: "बातचीत सुलझा दी गई"
15
+ event_resolved: "फ़िलहाल समस्या हल हो गई है। जब भी मदद चाहिए, फिर से संदेश भेजें।"
16
16
  event_reopened: "बातचीत फिर से खोली गई"
17
17
  error_send: "भेजा नहीं जा सका। कृपया फिर से कोशिश करें।"
18
18
  error_rate_limited: "बहुत सारे संदेश। कृपया थोड़ी देर रुककर फिर से कोशिश करें।"
@@ -12,7 +12,7 @@ hr:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "Spremi"
14
14
  email_saved: "Odgovorit ćemo i e-poštom."
15
- event_resolved: "Razgovor je riješen"
15
+ event_resolved: "Zasad je riješeno. Pošaljite novu poruku kad god trebate pomoć."
16
16
  event_reopened: "Razgovor je ponovno otvoren"
17
17
  error_send: "Slanje nije uspjelo. Pokušajte ponovno."
18
18
  error_rate_limited: "Previše poruka. Pričekajte trenutak i pokušajte ponovno."
@@ -12,7 +12,7 @@ id:
12
12
  email_placeholder: "anda@contoh.com"
13
13
  email_save: "Simpan"
14
14
  email_saved: "Kami juga akan membalas melalui email."
15
- event_resolved: "Percakapan selesai"
15
+ event_resolved: "Selesai untuk saat ini. Kirim pesan lagi kapan pun Anda membutuhkan bantuan."
16
16
  event_reopened: "Percakapan dibuka kembali"
17
17
  error_send: "Tidak dapat mengirim. Silakan coba lagi."
18
18
  error_rate_limited: "Terlalu banyak pesan. Mohon tunggu sebentar dan coba lagi."
@@ -12,7 +12,7 @@ it:
12
12
  email_placeholder: "tu@esempio.com"
13
13
  email_save: "Salva"
14
14
  email_saved: "Ti risponderemo anche via e-mail."
15
- event_resolved: "Conversazione risolta"
15
+ event_resolved: "Risolto per il momento. Invia un altro messaggio quando hai bisogno di aiuto."
16
16
  event_reopened: "Conversazione riaperta"
17
17
  error_send: "Invio non riuscito. Riprova."
18
18
  error_rate_limited: "Troppi messaggi. Attendi un momento e riprova."
@@ -12,7 +12,7 @@ ja:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "保存"
14
14
  email_saved: "メールでも返信いたします。"
15
- event_resolved: "会話が解決済みになりました"
15
+ event_resolved: "ひとまず解決しました。またお困りの際は、いつでもメッセージをお送りください。"
16
16
  event_reopened: "会話が再開されました"
17
17
  error_send: "送信できませんでした。もう一度お試しください。"
18
18
  error_rate_limited: "メッセージが多すぎます。少し待ってからもう一度お試しください。"
@@ -12,7 +12,7 @@ ko:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "저장"
14
14
  email_saved: "이메일로도 답변드리겠습니다."
15
- event_resolved: "대화가 해결되었습니다"
15
+ event_resolved: "일단 해결되었습니다. 도움이 필요하면 언제든 다시 메시지를 보내 주세요."
16
16
  event_reopened: "대화가 다시 열렸습니다"
17
17
  error_send: "전송하지 못했습니다. 다시 시도해 주세요."
18
18
  error_rate_limited: "메시지가 너무 많습니다. 잠시 후 다시 시도해 주세요."
@@ -12,7 +12,7 @@ lb:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "Späicheren"
14
14
  email_saved: "Mir äntweren och per E-Mail."
15
- event_resolved: "Gespréich geléist"
15
+ event_resolved: "Fir de Moment geléist. Schéckt eng nei Noriicht, wann Dir Hëllef braucht."
16
16
  event_reopened: "Gespréich nees opgemaach"
17
17
  error_send: "Konnt net geschéckt ginn. Probéiert w.e.g. nach eng Kéier."
18
18
  error_rate_limited: "Ze vill Noriichten. Waart w.e.g. e Moment a probéiert nach eng Kéier."
@@ -12,7 +12,7 @@ nl:
12
12
  email_placeholder: "jij@voorbeeld.nl"
13
13
  email_save: "Opslaan"
14
14
  email_saved: "We antwoorden ook per e-mail."
15
- event_resolved: "Gesprek opgelost"
15
+ event_resolved: "Voor nu opgelost. Stuur gerust een nieuw bericht als je hulp nodig hebt."
16
16
  event_reopened: "Gesprek heropend"
17
17
  error_send: "Versturen is niet gelukt. Probeer het opnieuw."
18
18
  error_rate_limited: "Te veel berichten. Wacht even en probeer het opnieuw."
@@ -12,7 +12,7 @@ pl:
12
12
  email_placeholder: "ty@przyklad.pl"
13
13
  email_save: "Zapisz"
14
14
  email_saved: "Odpowiemy również e-mailem."
15
- event_resolved: "Rozmowa rozwiązana"
15
+ event_resolved: "Na razie sprawa jest rozwiązana. Napisz ponownie, gdy potrzebujesz pomocy."
16
16
  event_reopened: "Rozmowa wznowiona"
17
17
  error_send: "Nie udało się wysłać. Spróbuj ponownie."
18
18
  error_rate_limited: "Zbyt wiele wiadomości. Poczekaj chwilę i spróbuj ponownie."
@@ -12,7 +12,7 @@ pt:
12
12
  email_placeholder: "voce@exemplo.com"
13
13
  email_save: "Salvar"
14
14
  email_saved: "Também responderemos por e-mail."
15
- event_resolved: "Conversa resolvida"
15
+ event_resolved: "Resolvido por enquanto. Envie outra mensagem sempre que precisar de ajuda."
16
16
  event_reopened: "Conversa reaberta"
17
17
  error_send: "Não foi possível enviar. Tente novamente."
18
18
  error_rate_limited: "Muitas mensagens. Aguarde um momento e tente novamente."
@@ -12,7 +12,7 @@ ro:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "Salvează"
14
14
  email_saved: "Vom răspunde și pe e-mail."
15
- event_resolved: "Conversație rezolvată"
15
+ event_resolved: "Rezolvat pentru moment. Trimiteți un alt mesaj când aveți nevoie de ajutor."
16
16
  event_reopened: "Conversație redeschisă"
17
17
  error_send: "Nu s-a putut trimite. Vă rugăm să încercați din nou."
18
18
  error_rate_limited: "Prea multe mesaje. Așteptați puțin și încercați din nou."
@@ -12,7 +12,7 @@ ru:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "Сохранить"
14
14
  email_saved: "Мы также ответим по электронной почте."
15
- event_resolved: "Диалог завершён"
15
+ event_resolved: "Пока вопрос решён. Напишите снова, когда понадобится помощь."
16
16
  event_reopened: "Диалог возобновлён"
17
17
  error_send: "Не удалось отправить. Пожалуйста, попробуйте ещё раз."
18
18
  error_rate_limited: "Слишком много сообщений. Подождите немного и попробуйте ещё раз."
@@ -12,7 +12,7 @@ th:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "บันทึก"
14
14
  email_saved: "เราจะตอบกลับทางอีเมลด้วย"
15
- event_resolved: "การสนทนาได้รับการแก้ไขแล้ว"
15
+ event_resolved: "แก้ไขเรียบร้อยแล้วในตอนนี้ ส่งข้อความมาได้อีกเมื่อคุณต้องการความช่วยเหลือ"
16
16
  event_reopened: "เปิดการสนทนาอีกครั้งแล้ว"
17
17
  error_send: "ส่งไม่สำเร็จ โปรดลองอีกครั้ง"
18
18
  error_rate_limited: "ข้อความมากเกินไป โปรดรอสักครู่แล้วลองอีกครั้ง"
@@ -12,7 +12,7 @@ tr:
12
12
  email_placeholder: "siz@ornek.com"
13
13
  email_save: "Kaydet"
14
14
  email_saved: "Ayrıca e-postayla da yanıtlayacağız."
15
- event_resolved: "Görüşme çözüldü"
15
+ event_resolved: "Şimdilik çözüldü. Yardıma ihtiyacınız olduğunda tekrar mesaj gönderin."
16
16
  event_reopened: "Görüşme yeniden açıldı"
17
17
  error_send: "Gönderilemedi. Lütfen tekrar deneyin."
18
18
  error_rate_limited: "Çok fazla mesaj. Lütfen biraz bekleyip tekrar deneyin."
@@ -12,7 +12,7 @@ uk:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "Зберегти"
14
14
  email_saved: "Ми також відповімо електронною поштою."
15
- event_resolved: "Розмову завершено"
15
+ event_resolved: "Наразі питання вирішено. Напишіть знову, коли знадобиться допомога."
16
16
  event_reopened: "Розмову відновлено"
17
17
  error_send: "Не вдалося надіслати. Будь ласка, спробуйте ще раз."
18
18
  error_rate_limited: "Забагато повідомлень. Зачекайте трохи та спробуйте ще раз."
@@ -12,7 +12,7 @@ ur:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "محفوظ کریں"
14
14
  email_saved: "ہم ای میل پر بھی جواب دیں گے۔"
15
- event_resolved: "گفتگو حل ہو گئی"
15
+ event_resolved: "فی الحال مسئلہ حل ہو گیا ہے۔ جب بھی مدد کی ضرورت ہو، دوبارہ پیغام بھیجیں۔"
16
16
  event_reopened: "گفتگو دوبارہ کھول دی گئی"
17
17
  error_send: "بھیجا نہیں جا سکا۔ براہ کرم دوبارہ کوشش کریں۔"
18
18
  error_rate_limited: "بہت زیادہ پیغامات۔ براہ کرم تھوڑا انتظار کریں اور دوبارہ کوشش کریں۔"
@@ -12,7 +12,7 @@ vi:
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "Lưu"
14
14
  email_saved: "Chúng tôi cũng sẽ trả lời qua email."
15
- event_resolved: "Cuộc trò chuyện đã được giải quyết"
15
+ event_resolved: "Tạm thời đã giải quyết xong. Hãy nhắn tin lại bất cứ khi nào bạn cần trợ giúp."
16
16
  event_reopened: "Cuộc trò chuyện đã được mở lại"
17
17
  error_send: "Không thể gửi. Vui lòng thử lại."
18
18
  error_rate_limited: "Quá nhiều tin nhắn. Vui lòng đợi một lát rồi thử lại."
@@ -12,7 +12,7 @@
12
12
  email_placeholder: "you@example.com"
13
13
  email_save: "保存"
14
14
  email_saved: "我们也会通过邮件回复您。"
15
- event_resolved: "对话已解决"
15
+ event_resolved: "问题暂时已解决。需要帮助时,随时再发消息。"
16
16
  event_reopened: "对话已重新打开"
17
17
  error_send: "发送失败,请重试。"
18
18
  error_rate_limited: "消息过多,请稍等片刻再重试。"
@@ -2,10 +2,9 @@
2
2
  * livechat dashboard — the little JavaScript the inbox needs, served as a
3
3
  * same-origin script so it works under strict CSPs (no inline handlers).
4
4
  *
5
- * On a conversation page it polls for new messages every few seconds. If the
6
- * reply box is empty the page just reloads to show them; if the agent is
7
- * mid-sentence it shows a "New messages" link instead — a reload must never
8
- * eat a half-written reply. Cmd/Ctrl+Enter sends.
5
+ * Thread polling appends new messages without disturbing a reply draft.
6
+ * The inbox list reloads only while the agent is not typing or searching.
7
+ * Cmd/Ctrl+Enter sends; submitting a reply restores focus after navigation.
9
8
  */
10
9
  (function () {
11
10
  "use strict";
@@ -359,6 +358,18 @@
359
358
  thread.appendChild(typingEl);
360
359
 
361
360
  if (replyBox) {
361
+ // Remember only the form destination for one navigation, not a draft.
362
+ // Ordinary visits to the split-pane inbox keep their existing focus.
363
+ var focusKey = "livechat:reply-focus";
364
+ try {
365
+ var focusAction = window.sessionStorage.getItem(focusKey);
366
+ window.sessionStorage.removeItem(focusKey);
367
+ if (focusAction === replyBox.form.action) replyBox.focus();
368
+ } catch (e) { /* storage may be disabled; the reply still submits */ }
369
+ replyBox.form.addEventListener("submit", function () {
370
+ try { window.sessionStorage.setItem(focusKey, replyBox.form.action); }
371
+ catch (e) { /* storage may be disabled */ }
372
+ });
362
373
  replyBox.addEventListener("keydown", function (event) {
363
374
  if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
364
375
  event.preventDefault();
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Livechat
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0'
5
5
  end
@@ -937,7 +937,8 @@
937
937
  if (unreadCount > 0) {
938
938
  if (!badge) {
939
939
  badge = document.createElement("span");
940
- badge.className = "lvc-opener-badge";
940
+ var hostClass = openers[i].getAttribute("data-livechat-badge-class");
941
+ badge.className = "lvc-opener-badge" + (hostClass ? " " + hostClass : "");
941
942
  openers[i].appendChild(badge);
942
943
  }
943
944
  badge.textContent = unreadCount > 9 ? "9+" : String(unreadCount);
@@ -1358,7 +1359,10 @@
1358
1359
  "#lvc-root #lvc-form{margin-bottom:calc(10px + env(safe-area-inset-bottom))}" +
1359
1360
  "}" +
1360
1361
  // Lives in host DOM (on data-livechat-open elements), so no #lvc-root prefix.
1361
- ".lvc-opener-badge{display:inline-flex;min-width:18px;height:18px;padding:0 5px;" +
1362
+ // A host that names its own badge classes gets none of this: unlayered
1363
+ // rules would beat its layered utility classes whatever their specificity.
1364
+ // :where() keeps the old single-class weight for hosts that override it.
1365
+ ":where([data-livechat-open]:not([data-livechat-badge-class]))>.lvc-opener-badge{display:inline-flex;min-width:18px;height:18px;padding:0 5px;" +
1362
1366
  "margin-inline-start:6px;border-radius:999px;background:#dc2626;color:#fff;" +
1363
1367
  "font-size:11px;font-weight:700;line-height:18px;align-items:center;" +
1364
1368
  "justify-content:center;vertical-align:middle}";
@@ -136,7 +136,7 @@ module Livechat
136
136
  emailPlaceholder: t(:email_placeholder, 'you@example.com'),
137
137
  emailSave: t(:email_save, 'Save'),
138
138
  emailSaved: t(:email_saved, 'We will also reply by email.'),
139
- eventResolved: t(:event_resolved, 'Conversation resolved'),
139
+ eventResolved: t(:event_resolved, 'Resolved for now. Send another message whenever you need help.'),
140
140
  eventReopened: t(:event_reopened, 'Conversation reopened'),
141
141
  errorSend: t(:error_send, 'Could not send. Please try again.'),
142
142
  unreadAria: t(:unread_aria, 'unread messages'),
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livechat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov