Recent searches
No recent searches
The number of unread messages in the widget
Posted Feb 04, 2022
We show the number of unread user messages if the widget is closed. But if the user refreshes the page or goes to another page, the data on the number of unread messages is lost. I remember that everything worked fine before, the data on the number of unread messages was not lost.
To increase the speed of the site and the speed of loading the page, I use the delayed loading of the script and form it by the script. Most of all, that's what it takes. How can I get the number of unread messages in this case?
We have custom launcher, and i added number with this script
zE('webWidget:on', 'chat:unreadMessages', (number) => {
if (number > 0) {
$(".lets-chat-button__number").text(number);
$(".lets-chat-button__text-inner").text("New");
checkButtonTextWidth();
} else {
$(".lets-chat-button__number").text('');
$(".lets-chat-button__text-inner").text("Let’s Chat");
}
})
And I also see that the default launcher displays the number of unread messages after the page reloads.
0
3
3 comments
Erica Girges
Thanks for posting your question to the Community. That definitely is strange. Was the number of unread messages persisting in the UI prior to the use of your site optimization script? If so, I definitely want to go ahead and see if there is another way we can meet your optimization needs while persisting the state of the total of unread messages.
Hope to hear back from you soon!
Best,
Erica - Dev Support
0
Yuliia Bon
Hi! Yes, the number of unread messages were shown correctly before optimization.
This is a script with some delay in which I form a script tag for the widget and my file.
And in my file I use a function that checks when the chat is connected so that there is no error that zE is not a function.
0
Erica Girges
Thank you for sharing these code snippets. Off the bat, I'm not seeing anything that would affect the persistence of state for displaying unread messages. I'm going to go ahead and create a ticket for you so we can deep dive more into this issue. Please keep an eye on your email for that correspondence from me.
Best,
Erica - Dev Support
0