Skip to content

Commit 8a3a793

Browse files
committed
show unread counter when new message arrives and webchat is hidden
1 parent da38600 commit 8a3a793

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

dist/hellotext.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/controllers/webchat_controller.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ var _default = /*#__PURE__*/function (_Controller) {
222222
behavior: 'smooth'
223223
});
224224
this.setOfflineTimeout();
225+
if (this.openValue) return;
226+
this.unreadCounterTarget.style.display = 'block';
227+
this.unreadCounterTarget.innerText = (parseInt(this.unreadCounterTarget.innerText) || 0) + 1;
225228
}
226229
}, {
227230
key: "onConversationAssignment",
@@ -432,4 +435,4 @@ _default.values = {
432435
default: undefined
433436
}
434437
};
435-
_default.targets = ['trigger', 'popover', 'input', 'attachmentInput', 'attachmentButton', 'errorMessageContainer', 'attachmentTemplate', 'attachmentContainer', 'attachment', 'messageTemplate', 'messagesContainer', 'title', 'onlineStatus', 'attachmentImage', 'footer', 'toolbar', 'message'];
438+
_default.targets = ['trigger', 'popover', 'input', 'attachmentInput', 'attachmentButton', 'errorMessageContainer', 'attachmentTemplate', 'attachmentContainer', 'attachment', 'messageTemplate', 'messagesContainer', 'title', 'onlineStatus', 'attachmentImage', 'footer', 'toolbar', 'message', 'unreadCounter'];

src/controllers/webchat_controller.js

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default class extends Controller {
4242
'footer',
4343
'toolbar',
4444
'message',
45+
'unreadCounter',
4546
]
4647

4748
initialize() {
@@ -238,6 +239,11 @@ export default class extends Controller {
238239

239240
element.scrollIntoView({ behavior: 'smooth' })
240241
this.setOfflineTimeout()
242+
243+
if(this.openValue) return
244+
245+
this.unreadCounterTarget.style.display = 'block'
246+
this.unreadCounterTarget.innerText = (parseInt(this.unreadCounterTarget.innerText) || 0) + 1
241247
}
242248

243249
onConversationAssignment(conversation) {

0 commit comments

Comments
 (0)