fix: Snooze conversation not working in Inbox view (#9875)

This commit is contained in:
Sivin Varghese
2024-08-07 18:57:29 +05:30
committed by GitHub
parent 89acbd8d09
commit 646cfb97e7
6 changed files with 84 additions and 64 deletions

View File

@@ -54,7 +54,7 @@ const showAdditionalActions = computed(
); );
const showOpenButton = computed(() => { const showOpenButton = computed(() => {
return isResolved.value || isSnoozed.value; return isPending.value || isSnoozed.value;
}); });
const getConversationParams = () => { const getConversationParams = () => {
@@ -208,7 +208,7 @@ useEmitter(CMD_RESOLVE_CONVERSATION, onCmdResolveConversation);
color-scheme="secondary" color-scheme="secondary"
size="small" size="small"
icon="book-clock" icon="book-clock"
@click="() => toggleStatus(STATUS_TYPE.PENDING)" @click="() => toggleStatus(wootConstants.STATUS_TYPE.PENDING)"
> >
{{ t('CONVERSATION.RESOLVE_DROPDOWN.MARK_PENDING') }} {{ t('CONVERSATION.RESOLVE_DROPDOWN.MARK_PENDING') }}
</woot-button> </woot-button>

View File

@@ -0,0 +1,72 @@
<script setup>
import { ref, computed } from 'vue';
import { useStore, useStoreGetters } from 'dashboard/composables/store';
import { useAlert } from 'dashboard/composables';
import { useI18n } from 'dashboard/composables/useI18n';
import { useEmitter } from 'dashboard/composables/emitter';
import { getUnixTime } from 'date-fns';
import { findSnoozeTime } from 'dashboard/helper/snoozeHelpers';
import { CMD_SNOOZE_CONVERSATION } from 'dashboard/routes/dashboard/commands/commandBarBusEvents';
import wootConstants from 'dashboard/constants/globals';
import CustomSnoozeModal from 'dashboard/components/CustomSnoozeModal.vue';
const store = useStore();
const getters = useStoreGetters();
const { t } = useI18n();
const showCustomSnoozeModal = ref(false);
const selectedChat = computed(() => getters.getSelectedChat.value);
const contextMenuChatId = computed(() => getters.getContextMenuChatId.value);
const toggleStatus = async (status, snoozedUntil) => {
await store.dispatch('toggleStatus', {
conversationId: selectedChat.value?.id || contextMenuChatId.value,
status,
snoozedUntil,
});
store.dispatch('setContextMenuChatId', null);
useAlert(t('CONVERSATION.CHANGE_STATUS'));
};
const onCmdSnoozeConversation = snoozeType => {
if (snoozeType === wootConstants.SNOOZE_OPTIONS.UNTIL_CUSTOM_TIME) {
showCustomSnoozeModal.value = true;
} else {
toggleStatus(
wootConstants.STATUS_TYPE.SNOOZED,
findSnoozeTime(snoozeType) || null
);
}
};
const chooseSnoozeTime = customSnoozeTime => {
showCustomSnoozeModal.value = false;
if (customSnoozeTime) {
toggleStatus(
wootConstants.STATUS_TYPE.SNOOZED,
getUnixTime(customSnoozeTime)
);
}
};
const hideCustomSnoozeModal = () => {
// if we select custom snooze and the custom snooze modal is open
// Then if the custom snooze modal is closed then set the context menu chat id to null
store.dispatch('setContextMenuChatId', null);
showCustomSnoozeModal.value = false;
};
useEmitter(CMD_SNOOZE_CONVERSATION, onCmdSnoozeConversation);
</script>
<template>
<woot-modal
:show.sync="showCustomSnoozeModal"
:on-close="hideCustomSnoozeModal"
>
<CustomSnoozeModal
@close="hideCustomSnoozeModal"
@chooseTime="chooseSnoozeTime"
/>
</woot-modal>
</template>

View File

@@ -1,4 +1,3 @@
<!-- eslint-disable vue/attribute-hyphenation -->
<script> <script>
import '@chatwoot/ninja-keys'; import '@chatwoot/ninja-keys';
import wootConstants from 'dashboard/constants/globals'; import wootConstants from 'dashboard/constants/globals';
@@ -97,11 +96,12 @@ export default {
}; };
</script> </script>
<!-- eslint-disable vue/attribute-hyphenation -->
<template> <template>
<ninja-keys <ninja-keys
ref="ninjakeys" ref="ninjakeys"
no-auto-load-md-icons noAutoLoadMdIcons
hide-breadcrumbs hideBreadcrumbs
:placeholder="placeholder" :placeholder="placeholder"
@selected="onSelected" @selected="onSelected"
@closed="onClosed" @closed="onClosed"

View File

@@ -53,7 +53,7 @@ const INBOX_SNOOZE_EVENTS = [
}, },
{ {
id: SNOOZE_OPTIONS.UNTIL_CUSTOM_TIME, id: SNOOZE_OPTIONS.UNTIL_CUSTOM_TIME,
title: 'COMMAND_BAR.COMMANDS.CUSTOM', title: 'COMMAND_BAR.COMMANDS.UNTIL_CUSTOM_TIME',
section: 'COMMAND_BAR.SECTIONS.SNOOZE_NOTIFICATION', section: 'COMMAND_BAR.SECTIONS.SNOOZE_NOTIFICATION',
parent: 'snooze_notification', parent: 'snooze_notification',
icon: ICON_SNOOZE_NOTIFICATION, icon: ICON_SNOOZE_NOTIFICATION,

View File

@@ -1,23 +1,19 @@
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { useAlert } from 'dashboard/composables';
import { useUISettings } from 'dashboard/composables/useUISettings'; import { useUISettings } from 'dashboard/composables/useUISettings';
import { getUnixTime } from 'date-fns';
import ChatList from '../../../components/ChatList.vue'; import ChatList from '../../../components/ChatList.vue';
import ConversationBox from '../../../components/widgets/conversation/ConversationBox.vue'; import ConversationBox from '../../../components/widgets/conversation/ConversationBox.vue';
import PopOverSearch from './search/PopOverSearch.vue'; import PopOverSearch from './search/PopOverSearch.vue';
import CustomSnoozeModal from 'dashboard/components/CustomSnoozeModal.vue';
import wootConstants from 'dashboard/constants/globals'; import wootConstants from 'dashboard/constants/globals';
import { BUS_EVENTS } from 'shared/constants/busEvents'; import { BUS_EVENTS } from 'shared/constants/busEvents';
import { CMD_SNOOZE_CONVERSATION } from 'dashboard/routes/dashboard/commands/commandBarBusEvents'; import CmdBarConversationSnooze from 'dashboard/routes/dashboard/commands/CmdBarConversationSnooze.vue';
import { findSnoozeTime } from 'dashboard/helper/snoozeHelpers';
export default { export default {
components: { components: {
ChatList, ChatList,
ConversationBox, ConversationBox,
PopOverSearch, PopOverSearch,
CustomSnoozeModal, CmdBarConversationSnooze,
}, },
props: { props: {
inboxId: { inboxId: {
@@ -56,14 +52,12 @@ export default {
data() { data() {
return { return {
showSearchModal: false, showSearchModal: false,
showCustomSnoozeModal: false,
}; };
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
chatList: 'getAllConversations', chatList: 'getAllConversations',
currentChat: 'getSelectedChat', currentChat: 'getSelectedChat',
contextMenuChatId: 'getContextMenuChatId',
}), }),
showConversationList() { showConversationList() {
return this.isOnExpandedLayout ? !this.conversationId : true; return this.isOnExpandedLayout ? !this.conversationId : true;
@@ -100,10 +94,6 @@ export default {
this.$watch('chatList.length', () => { this.$watch('chatList.length', () => {
this.setActiveChat(); this.setActiveChat();
}); });
this.$emitter.on(CMD_SNOOZE_CONVERSATION, this.onCmdSnoozeConversation);
},
beforeDestroy() {
this.$emitter.off(CMD_SNOOZE_CONVERSATION, this.onCmdSnoozeConversation);
}, },
methods: { methods: {
@@ -178,43 +168,6 @@ export default {
closeSearch() { closeSearch() {
this.showSearchModal = false; this.showSearchModal = false;
}, },
onCmdSnoozeConversation(snoozeType) {
if (snoozeType === wootConstants.SNOOZE_OPTIONS.UNTIL_CUSTOM_TIME) {
this.showCustomSnoozeModal = true;
} else {
this.toggleStatus(
wootConstants.STATUS_TYPE.SNOOZED,
findSnoozeTime(snoozeType) || null
);
}
},
chooseSnoozeTime(customSnoozeTime) {
this.showCustomSnoozeModal = false;
if (customSnoozeTime) {
this.toggleStatus(
wootConstants.STATUS_TYPE.SNOOZED,
getUnixTime(customSnoozeTime)
);
}
},
toggleStatus(status, snoozedUntil) {
this.$store
.dispatch('toggleStatus', {
conversationId: this.currentChat?.id || this.contextMenuChatId,
status,
snoozedUntil,
})
.then(() => {
this.$store.dispatch('setContextMenuChatId', null);
useAlert(this.$t('CONVERSATION.CHANGE_STATUS'));
});
},
hideCustomSnoozeModal() {
// if we select custom snooze and the custom snooze modal is open
// Then if the custom snooze modal is closed then set the context menu chat id to null
this.$store.dispatch('setContextMenuChatId', null);
this.showCustomSnoozeModal = false;
},
}, },
}; };
</script> </script>
@@ -243,15 +196,7 @@ export default {
:is-on-expanded-layout="isOnExpandedLayout" :is-on-expanded-layout="isOnExpandedLayout"
@contactPanelToggle="onToggleContactPanel" @contactPanelToggle="onToggleContactPanel"
/> />
<woot-modal <CmdBarConversationSnooze />
:show.sync="showCustomSnoozeModal"
:on-close="hideCustomSnoozeModal"
>
<CustomSnoozeModal
@close="hideCustomSnoozeModal"
@chooseTime="chooseSnoozeTime"
/>
</woot-modal>
</section> </section>
</template> </template>

View File

@@ -8,12 +8,14 @@ import InboxCard from './components/InboxCard.vue';
import InboxListHeader from './components/InboxListHeader.vue'; import InboxListHeader from './components/InboxListHeader.vue';
import { INBOX_EVENTS } from 'dashboard/helper/AnalyticsHelper/events'; import { INBOX_EVENTS } from 'dashboard/helper/AnalyticsHelper/events';
import IntersectionObserver from 'dashboard/components/IntersectionObserver.vue'; import IntersectionObserver from 'dashboard/components/IntersectionObserver.vue';
import CmdBarConversationSnooze from 'dashboard/routes/dashboard/commands/CmdBarConversationSnooze.vue';
export default { export default {
components: { components: {
InboxCard, InboxCard,
InboxListHeader, InboxListHeader,
IntersectionObserver, IntersectionObserver,
CmdBarConversationSnooze,
}, },
setup() { setup() {
const { uiSettings } = useUISettings(); const { uiSettings } = useUISettings();
@@ -209,5 +211,6 @@ export default {
</div> </div>
</div> </div>
<router-view /> <router-view />
<CmdBarConversationSnooze />
</section> </section>
</template> </template>