mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 11:37:58 +00:00
feat: Hides dismissed campaigns while browsing [cw-33] (#6842)
* Chore: moves localstorage helper as a shared utility and refactors constants * Refactors constants file * feat: Hides dismissed campaigns while browsing * Snoozes all campaigns for an hour after dismissing * Fixes error with date parsing * Snooze ongoing campaigns * Review fixes --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
committed by
GitHub
parent
d95283f5c2
commit
2f2cdd7e7c
@@ -36,6 +36,7 @@ import {
|
||||
} from 'shared/helpers/AudioNotificationHelper';
|
||||
import { isFlatWidgetStyle } from './settingsHelper';
|
||||
import { popoutChatWindow } from '../widget/helpers/popoutHelper';
|
||||
import addHours from 'date-fns/addHours';
|
||||
|
||||
const updateAuthCookie = cookieContent =>
|
||||
Cookies.set('cw_conversation', cookieContent, {
|
||||
@@ -43,6 +44,14 @@ const updateAuthCookie = cookieContent =>
|
||||
sameSite: 'Lax',
|
||||
});
|
||||
|
||||
const updateCampaignReadStatus = () => {
|
||||
const expireBy = addHours(new Date(), 1);
|
||||
Cookies.set('cw_snooze_campaigns_till', Number(expireBy), {
|
||||
expires: expireBy,
|
||||
sameSite: 'Lax',
|
||||
});
|
||||
};
|
||||
|
||||
export const IFrameHelper = {
|
||||
getUrl({ baseUrl, websiteToken }) {
|
||||
return `${baseUrl}/widget?website_token=${websiteToken}`;
|
||||
@@ -147,6 +156,7 @@ export const IFrameHelper = {
|
||||
loaded: message => {
|
||||
updateAuthCookie(message.config.authToken);
|
||||
window.$chatwoot.hasLoaded = true;
|
||||
const campaignsSnoozedTill = Cookies.get('cw_snooze_campaigns_till');
|
||||
IFrameHelper.sendMessage('config-set', {
|
||||
locale: window.$chatwoot.locale,
|
||||
position: window.$chatwoot.position,
|
||||
@@ -154,6 +164,7 @@ export const IFrameHelper = {
|
||||
showPopoutButton: window.$chatwoot.showPopoutButton,
|
||||
widgetStyle: window.$chatwoot.widgetStyle,
|
||||
darkMode: window.$chatwoot.darkMode,
|
||||
campaignsSnoozedTill,
|
||||
});
|
||||
IFrameHelper.onLoad({
|
||||
widgetColor: message.config.channelConfig.widgetColor,
|
||||
@@ -192,6 +203,10 @@ export const IFrameHelper = {
|
||||
updateAuthCookie(widgetAuthToken);
|
||||
},
|
||||
|
||||
setCampaignReadOn() {
|
||||
updateCampaignReadStatus();
|
||||
},
|
||||
|
||||
toggleBubble: state => {
|
||||
let bubbleState = {};
|
||||
if (state === 'open') {
|
||||
|
||||
Reference in New Issue
Block a user