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,4 +1,3 @@
|
||||
import Vue from 'vue';
|
||||
import types from '../../mutation-types';
|
||||
|
||||
export const mutations = {
|
||||
@@ -9,8 +8,8 @@ export const mutations = {
|
||||
};
|
||||
},
|
||||
[types.CLEAR_NOTIFICATIONS]: $state => {
|
||||
Vue.set($state, 'records', {});
|
||||
Vue.set($state.uiFlags, 'isAllNotificationsLoaded', false);
|
||||
$state.records = {};
|
||||
$state.uiFlags.isAllNotificationsLoaded = false;
|
||||
},
|
||||
[types.SET_NOTIFICATIONS_META]: ($state, data) => {
|
||||
const {
|
||||
@@ -19,12 +18,10 @@ export const mutations = {
|
||||
unread_count: unreadCount,
|
||||
} = data;
|
||||
|
||||
Vue.set($state.meta, 'count', count);
|
||||
Vue.set($state.meta, 'currentPage', currentPage);
|
||||
Vue.set($state.meta, 'unreadCount', unreadCount);
|
||||
$state.meta = { ...$state.meta, count, currentPage, unreadCount };
|
||||
},
|
||||
[types.SET_NOTIFICATIONS_UNREAD_COUNT]: ($state, count) => {
|
||||
Vue.set($state.meta, 'unreadCount', count < 0 ? 0 : count);
|
||||
$state.meta.unreadCount = count < 0 ? 0 : count;
|
||||
},
|
||||
[types.SET_NOTIFICATIONS]: ($state, data) => {
|
||||
data.forEach(notification => {
|
||||
@@ -36,73 +33,75 @@ export const mutations = {
|
||||
// On reconnect, if there is existing notification with same primary_actor_id,
|
||||
// it will be deleted and the new one will be added. So it will solve with duplicate notification
|
||||
if (existingNotification) {
|
||||
Vue.delete($state.records, existingNotification.id);
|
||||
$state.records[existingNotification.id] = undefined;
|
||||
}
|
||||
Vue.set($state.records, notification.id, {
|
||||
|
||||
$state.records[notification.id] = {
|
||||
...($state.records[notification.id] || {}),
|
||||
...notification,
|
||||
});
|
||||
};
|
||||
});
|
||||
},
|
||||
[types.READ_NOTIFICATION]: ($state, { id, read_at }) => {
|
||||
Vue.set($state.records[id], 'read_at', read_at);
|
||||
$state.records[id].read_at = read_at;
|
||||
},
|
||||
[types.UPDATE_ALL_NOTIFICATIONS]: $state => {
|
||||
Object.values($state.records).forEach(item => {
|
||||
Vue.set($state.records[item.id], 'read_at', true);
|
||||
$state.records[item.id].read_at = true;
|
||||
});
|
||||
},
|
||||
|
||||
[types.ADD_NOTIFICATION]($state, data) {
|
||||
const { notification, unread_count: unreadCount, count } = data;
|
||||
Vue.set($state.records, notification.id, {
|
||||
|
||||
$state.records[notification.id] = {
|
||||
...($state.records[notification.id] || {}),
|
||||
...notification,
|
||||
});
|
||||
Vue.set($state.meta, 'unreadCount', unreadCount);
|
||||
Vue.set($state.meta, 'count', count);
|
||||
};
|
||||
$state.meta.unreadCount = unreadCount;
|
||||
$state.meta.count = count;
|
||||
},
|
||||
[types.UPDATE_NOTIFICATION]($state, data) {
|
||||
const { notification, unread_count: unreadCount, count } = data;
|
||||
Vue.set($state.records, notification.id, {
|
||||
$state.records[notification.id] = {
|
||||
...($state.records[notification.id] || {}),
|
||||
...notification,
|
||||
});
|
||||
Vue.set($state.meta, 'unreadCount', unreadCount);
|
||||
Vue.set($state.meta, 'count', count);
|
||||
};
|
||||
$state.meta.unreadCount = unreadCount;
|
||||
$state.meta.count = count;
|
||||
},
|
||||
[types.DELETE_NOTIFICATION]($state, data) {
|
||||
const { notification, unread_count: unreadCount, count } = data;
|
||||
Vue.delete($state.records, notification.id);
|
||||
Vue.set($state.meta, 'unreadCount', unreadCount);
|
||||
Vue.set($state.meta, 'count', count);
|
||||
$state.records[notification.id] = undefined;
|
||||
$state.meta.unreadCount = unreadCount;
|
||||
$state.meta.count = count;
|
||||
},
|
||||
[types.SET_ALL_NOTIFICATIONS_LOADED]: $state => {
|
||||
Vue.set($state.uiFlags, 'isAllNotificationsLoaded', true);
|
||||
$state.uiFlags.isAllNotificationsLoaded = true;
|
||||
},
|
||||
|
||||
[types.DELETE_READ_NOTIFICATIONS]: $state => {
|
||||
Object.values($state.records).forEach(item => {
|
||||
if (item.read_at) {
|
||||
Vue.delete($state.records, item.id);
|
||||
$state.records[item.id] = undefined;
|
||||
}
|
||||
});
|
||||
},
|
||||
[types.DELETE_ALL_NOTIFICATIONS]: $state => {
|
||||
Vue.set($state, 'records', {});
|
||||
$state.records = {};
|
||||
},
|
||||
|
||||
[types.SNOOZE_NOTIFICATION]: ($state, { id, snoozed_until }) => {
|
||||
Vue.set($state.records[id], 'snoozed_until', snoozed_until);
|
||||
$state.records[id].snoozed_until = snoozed_until;
|
||||
},
|
||||
|
||||
[types.SET_NOTIFICATION_FILTERS]: ($state, filters) => {
|
||||
Vue.set($state, 'notificationFilters', filters);
|
||||
$state.notificationFilters = filters;
|
||||
},
|
||||
[types.UPDATE_NOTIFICATION_FILTERS]: ($state, filters) => {
|
||||
Vue.set($state, 'notificationFilters', {
|
||||
$state.notificationFilters = {
|
||||
...$state.notificationFilters,
|
||||
...filters,
|
||||
});
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user