Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions webplugin/js/app/kommunicate-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,36 @@ KommunicateUI = {
faqCategoriesReady: false,
faqCategoryRequestPending: false,
faqAppData: null,
closedConversationBannerTimeoutId: null,
closedConversationBannerTabId: null,
pendingClosedConversationBanner: false,
convRatedTabIds: {
// using for optimize the feedback get api call
// [tabId]: 1 => init the feedback api
// [tabId]: 2 => conversations rated
},
clearClosedConversationBannerTimeout: function () {
if (KommunicateUI.closedConversationBannerTimeoutId) {
clearTimeout(KommunicateUI.closedConversationBannerTimeoutId);
KommunicateUI.closedConversationBannerTimeoutId = null;
}
KommunicateUI.closedConversationBannerTabId = null;
KommunicateUI.pendingClosedConversationBanner = false;
},
scheduleClosedConversationBanner: function (delayMs, tabId) {
KommunicateUI.clearClosedConversationBannerTimeout();
KommunicateUI.pendingClosedConversationBanner = true;
KommunicateUI.closedConversationBannerTabId = tabId;
KommunicateUI.closedConversationBannerTimeoutId = setTimeout(function () {
if (
!KommunicateUI.pendingClosedConversationBanner ||
KommunicateUI.closedConversationBannerTabId !== CURRENT_GROUP_DATA.tabId
) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Gate delayed banner on true active tab id

The timeout callback drops the banner whenever CURRENT_GROUP_DATA.tabId no longer matches the scheduled tab, but that global is reassigned for any incoming KM_STATUS message (see mck-sidebox-1.0.js around the status handler where CURRENT_GROUP_DATA.tabId = resp.message.groupId). In practice, if conversation A is resolved and scheduled, then a status update for conversation B arrives before the delay expires, this check returns early and the resolved banner/input lock never appears for A even if A is still the open chat. This introduces a missed-resolved-state regression under normal multi-conversation socket traffic.

Useful? React with 👍 / 👎.

return;
}
KommunicateUI.showClosedConversationBanner(true);
}, delayMs);
},
faqSVGImage:
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><circle class="km-custom-widget-fill" cx="12" cy="12" r="12" fill="#5553B7" fill-rule="nonzero" opacity=".654"/><g transform="translate(6.545 5.818)"><polygon fill="#FFF" points=".033 2.236 .033 12.057 10.732 12.057 10.732 .02 3.324 .02"/><rect class="km-custom-widget-fill" width="6.433" height="1" x="2.144" y="5.468" fill="#5553B7" fill-rule="nonzero" opacity=".65" rx=".5"/><rect class="km-custom-widget-fill" width="4.289" height="1" x="2.144" y="8.095" fill="#5553B7" fill-rule="nonzero" opacity=".65" rx=".5"/><polygon class="km-custom-widget-fill" fill="#5553B7" points="2.656 .563 3.384 2.487 1.162 3.439" opacity=".65" transform="rotate(26 2.273 2.001)"/></g></g></svg>',
CONSTS: {},
Expand Down Expand Up @@ -1379,6 +1404,9 @@ KommunicateUI = {
KommunicateUI.triggerCSAT(triggeredByBot);
},
showClosedConversationBanner: function (isConversationClosed) {
if (!isConversationClosed) {
KommunicateUI.clearClosedConversationBannerTimeout();
}
var isConvRated = document.getElementsByClassName('mck-rated').length > 0;
if (kommunicate._globals.oneTimeRating) {
if (isConvRated && CURRENT_GROUP_DATA.tabId) {
Expand Down
10 changes: 7 additions & 3 deletions webplugin/js/app/mck-sidebox-1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -4221,6 +4221,9 @@ const firstVisibleMsg = {
});
_this.restartConversation = function (event) {
kmWidgetEvents.eventTracking(eventMapping.onRestartConversationClick);
if (KommunicateUI.closedConversationBannerTabId === CURRENT_GROUP_DATA.tabId) {
KommunicateUI.clearClosedConversationBannerTimeout();
}
if (
event.currentTarget.id == 'km-restart-conversation' &&
appOptions.restartConversationByUser
Expand Down Expand Up @@ -15515,9 +15518,10 @@ const firstVisibleMsg = {
mckMessageLayout.isMessageSentByBot(resp.message, contact) &&
!CURRENT_GROUP_DATA.TOKENIZE_RESPONSE
) {
setTimeout(function () {
KommunicateUI.showClosedConversationBanner(true);
}, MCK_BOT_MESSAGE_DELAY);
KommunicateUI.scheduleClosedConversationBanner(
MCK_BOT_MESSAGE_DELAY,
CURRENT_GROUP_DATA.tabId
);
} else {
KommunicateUI.isConvJustResolved = !!!KommunicateUI.isConvJustResolved;
KommunicateUI.showClosedConversationBanner(true);
Comment thread
sentry[bot] marked this conversation as resolved.
Outdated
Expand Down
Loading