feat: Vite + vue 3 💚 (#10047)
Fixes https://github.com/chatwoot/chatwoot/issues/8436 Fixes https://github.com/chatwoot/chatwoot/issues/9767 Fixes https://github.com/chatwoot/chatwoot/issues/10156 Fixes https://github.com/chatwoot/chatwoot/issues/6031 Fixes https://github.com/chatwoot/chatwoot/issues/5696 Fixes https://github.com/chatwoot/chatwoot/issues/9250 Fixes https://github.com/chatwoot/chatwoot/issues/9762 --------- Co-authored-by: Pranav <pranavrajs@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
import analyticsHelper from '.';
|
||||
|
||||
export default {
|
||||
// This function is called when the Vue plugin is installed
|
||||
install(Vue) {
|
||||
analyticsHelper.init();
|
||||
Vue.prototype.$analytics = analyticsHelper;
|
||||
// Add a shorthand function for the track method on the helper module
|
||||
Vue.prototype.$track = analyticsHelper.track.bind(analyticsHelper);
|
||||
},
|
||||
};
|
||||
@@ -24,13 +24,13 @@ class DashboardAudioNotificationHelper {
|
||||
this.audioAlertTone = 'ding';
|
||||
}
|
||||
|
||||
setInstanceValues = ({
|
||||
setInstanceValues({
|
||||
currentUser,
|
||||
alwaysPlayAudioAlert,
|
||||
alertIfUnreadConversationExist,
|
||||
audioAlertType,
|
||||
audioAlertTone,
|
||||
}) => {
|
||||
}) {
|
||||
this.audioAlertType = audioAlertType;
|
||||
this.playAlertOnlyWhenHidden = !alwaysPlayAudioAlert;
|
||||
this.alertIfUnreadConversationExist = alertIfUnreadConversationExist;
|
||||
@@ -41,9 +41,9 @@ class DashboardAudioNotificationHelper {
|
||||
document.addEventListener(e, this.onAudioListenEvent, false);
|
||||
});
|
||||
initFaviconSwitcher();
|
||||
};
|
||||
}
|
||||
|
||||
onAudioListenEvent = async () => {
|
||||
async onAudioListenEvent() {
|
||||
try {
|
||||
await getAlertAudio('', {
|
||||
type: 'dashboard',
|
||||
@@ -56,14 +56,15 @@ class DashboardAudioNotificationHelper {
|
||||
} catch (error) {
|
||||
// Ignore audio fetch errors
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
executeRecurringNotification = () => {
|
||||
if (!window.WOOT || !window.WOOT.$store) {
|
||||
executeRecurringNotification() {
|
||||
if (!window.WOOT_STORE) {
|
||||
this.clearSetTimeout();
|
||||
return;
|
||||
}
|
||||
const mineConversation = window.WOOT.$store.getters.getMineChats({
|
||||
|
||||
const mineConversation = window.WOOT_STORE.getters.getMineChats({
|
||||
assigneeType: 'me',
|
||||
status: 'open',
|
||||
});
|
||||
@@ -78,9 +79,9 @@ class DashboardAudioNotificationHelper {
|
||||
showBadgeOnFavicon();
|
||||
}
|
||||
this.clearSetTimeout();
|
||||
};
|
||||
}
|
||||
|
||||
clearSetTimeout = () => {
|
||||
clearSetTimeout() {
|
||||
if (this.recurringNotificationTimer) {
|
||||
clearTimeout(this.recurringNotificationTimer);
|
||||
}
|
||||
@@ -88,9 +89,9 @@ class DashboardAudioNotificationHelper {
|
||||
this.executeRecurringNotification,
|
||||
NOTIFICATION_TIME
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
playAudioEvery30Seconds = () => {
|
||||
playAudioEvery30Seconds() {
|
||||
// Audio alert is disabled dismiss the timer
|
||||
if (this.audioAlertType === 'none') {
|
||||
return;
|
||||
@@ -101,26 +102,26 @@ class DashboardAudioNotificationHelper {
|
||||
}
|
||||
|
||||
this.clearSetTimeout();
|
||||
};
|
||||
}
|
||||
|
||||
isConversationAssignedToCurrentUser = message => {
|
||||
isConversationAssignedToCurrentUser(message) {
|
||||
const conversationAssigneeId = message?.conversation?.assignee_id;
|
||||
return conversationAssigneeId === this.currentUserId;
|
||||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
isMessageFromCurrentConversation = message => {
|
||||
isMessageFromCurrentConversation(message) {
|
||||
return (
|
||||
window.WOOT.$store.getters.getSelectedChat?.id === message.conversation_id
|
||||
window.WOOT_STORE.getters.getSelectedChat?.id === message.conversation_id
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
isMessageFromCurrentUser = message => {
|
||||
isMessageFromCurrentUser(message) {
|
||||
return message?.sender_id === this.currentUserId;
|
||||
};
|
||||
}
|
||||
|
||||
isUserHasConversationPermission = () => {
|
||||
const currentAccountId = window.WOOT.$store.getters.getCurrentAccountId;
|
||||
isUserHasConversationPermission() {
|
||||
const currentAccountId = window.WOOT_STORE.getters.getCurrentAccountId;
|
||||
// Get the user permissions for the current account
|
||||
const userPermissions = getUserPermissions(
|
||||
this.currentUser,
|
||||
@@ -131,16 +132,16 @@ class DashboardAudioNotificationHelper {
|
||||
permission => userPermissions.includes(permission)
|
||||
);
|
||||
return hasRequiredPermission;
|
||||
};
|
||||
}
|
||||
|
||||
shouldNotifyOnMessage = message => {
|
||||
shouldNotifyOnMessage(message) {
|
||||
if (this.audioAlertType === 'mine') {
|
||||
return this.isConversationAssignedToCurrentUser(message);
|
||||
}
|
||||
return this.audioAlertType === 'all';
|
||||
};
|
||||
}
|
||||
|
||||
onNewMessage = message => {
|
||||
onNewMessage(message) {
|
||||
// If the user does not have the permission to view the conversation, then dismiss the alert
|
||||
if (!this.isUserHasConversationPermission()) {
|
||||
return;
|
||||
@@ -173,7 +174,9 @@ class DashboardAudioNotificationHelper {
|
||||
window.playAudioAlert();
|
||||
showBadgeOnFavicon();
|
||||
this.playAudioEvery30Seconds();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default new DashboardAudioNotificationHelper();
|
||||
const notifHelper = new DashboardAudioNotificationHelper();
|
||||
window.notifHelper = notifHelper;
|
||||
export default notifHelper;
|
||||
|
||||
@@ -85,7 +85,8 @@ class ReconnectService {
|
||||
};
|
||||
|
||||
fetchConversationMessagesOnReconnect = async () => {
|
||||
const { conversation_id: conversationId } = this.router.currentRoute.params;
|
||||
const { conversation_id: conversationId } =
|
||||
this.router.currentRoute.value.params;
|
||||
if (conversationId) {
|
||||
await this.store.dispatch('syncActiveConversationMessages', {
|
||||
conversationId: Number(conversationId),
|
||||
@@ -109,7 +110,7 @@ class ReconnectService {
|
||||
};
|
||||
|
||||
handleRouteSpecificFetch = async () => {
|
||||
const currentRoute = this.router.currentRoute.name;
|
||||
const currentRoute = this.router.currentRoute.value.name;
|
||||
if (isAConversationRoute(currentRoute, true)) {
|
||||
await this.fetchConversationsOnReconnect();
|
||||
await this.fetchConversationMessagesOnReconnect();
|
||||
@@ -123,7 +124,8 @@ class ReconnectService {
|
||||
};
|
||||
|
||||
setConversationLastMessageId = async () => {
|
||||
const { conversation_id: conversationId } = this.router.currentRoute.params;
|
||||
const { conversation_id: conversationId } =
|
||||
this.router.currentRoute.value.params;
|
||||
if (conversationId) {
|
||||
await this.store.dispatch('setConversationLastMessageId', {
|
||||
conversationId: Number(conversationId),
|
||||
|
||||
@@ -201,7 +201,7 @@ class ActionCableConnector extends BaseActionCableConnector {
|
||||
}
|
||||
|
||||
export default {
|
||||
init(pubsubToken) {
|
||||
return new ActionCableConnector(window.WOOT, pubsubToken);
|
||||
init(store, pubsubToken) {
|
||||
return new ActionCableConnector({ $store: store }, pubsubToken);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
import { debounce } from '@chatwoot/utils';
|
||||
|
||||
const RESIZE_OBSERVER_DEBOUNCE_TIME = 100;
|
||||
|
||||
function createResizeObserver(el, binding) {
|
||||
const { value } = binding;
|
||||
const observer = new ResizeObserver(
|
||||
debounce(entries => {
|
||||
const entry = entries[0];
|
||||
if (entry && value && typeof value === 'function') {
|
||||
value(entry);
|
||||
}
|
||||
}, RESIZE_OBSERVER_DEBOUNCE_TIME)
|
||||
);
|
||||
|
||||
el.cwResizeObserver = observer;
|
||||
observer.observe(el);
|
||||
}
|
||||
|
||||
function destroyResizeObserver(el) {
|
||||
if (el.cwResizeObserver) {
|
||||
el.cwResizeObserver.unobserve(el);
|
||||
el.cwResizeObserver.disconnect();
|
||||
delete el.cwResizeObserver;
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
bind(el, binding) {
|
||||
createResizeObserver(el, binding);
|
||||
},
|
||||
update(el, binding) {
|
||||
if (binding.oldValue !== binding.value) {
|
||||
destroyResizeObserver(el);
|
||||
createResizeObserver(el, binding);
|
||||
}
|
||||
},
|
||||
unbind(el) {
|
||||
destroyResizeObserver(el);
|
||||
},
|
||||
};
|
||||
@@ -4,8 +4,7 @@ import {
|
||||
MessageMarkdownSerializer,
|
||||
} from '@chatwoot/prosemirror-schema';
|
||||
import { replaceVariablesInMessage } from '@chatwoot/utils';
|
||||
|
||||
import * as Sentry from '@sentry/browser';
|
||||
import * as Sentry from '@sentry/vue';
|
||||
|
||||
/**
|
||||
* The delimiter used to separate the signature from the rest of the body.
|
||||
|
||||
Reference in New Issue
Block a user