fix(conversations): 修复状态切换与历史会话路由

- 处理历史主键与 display_id 冲突,确保消息和状态操作命中同一会话
- 允许已软删除收件箱中的历史会话切换状态
- 解决会话后自动打开列表中的相邻会话
This commit is contained in:
Rogee
2026-08-06 10:08:05 +08:00
parent cb50726620
commit 8f2cc12628
5 changed files with 117 additions and 9 deletions
@@ -1,5 +1,6 @@
<script setup>
import { ref, computed } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useAlert } from 'dashboard/composables';
import { useToggle } from '@vueuse/core';
import { useI18n } from 'vue-i18n';
@@ -19,9 +20,20 @@ import {
import ButtonGroup from 'dashboard/components-next/buttonGroup/ButtonGroup.vue';
import Button from 'dashboard/components-next/button/Button.vue';
import ConversationResolveAttributesModal from 'dashboard/components-next/ConversationWorkflow/ConversationResolveAttributesModal.vue';
import {
conversationListPageURL,
} from 'dashboard/helper/URLHelper';
import {
isOnMentionsView,
isOnParticipatingView,
isOnUnattendedView,
isOnFoldersView,
} from 'dashboard/store/modules/conversations/helpers/actionHelpers';
const store = useStore();
const getters = useStoreGetters();
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
const { checkMissingAttributes } = useConversationRequiredAttributes();
@@ -35,6 +47,30 @@ const openDropdown = () => toggleDropdown(true);
const currentChat = computed(() => getters.getSelectedChat.value);
const redirectToConversationList = () => {
const {
params: { accountId, inbox_id: inboxId, label, teamId, id: customViewId },
name,
} = route;
let conversationType = '';
if (isOnMentionsView({ route: { name } })) conversationType = 'mention';
else if (isOnParticipatingView({ route: { name } })) {
conversationType = 'participating';
} else if (isOnUnattendedView({ route: { name } })) {
conversationType = 'unattended';
}
router.push(
conversationListPageURL({
accountId,
conversationType,
customViewId: isOnFoldersView({ route: { name } }) ? customViewId : 0,
inboxId,
label,
teamId,
})
);
};
const isOpen = computed(
() => currentChat.value.status === wootConstants.STATUS_TYPE.OPEN
);
@@ -84,9 +120,13 @@ const openSnoozeModal = () => {
const toggleStatus = (status, snoozedUntil, customAttributes = null) => {
closeDropdown();
isLoading.value = true;
const conversationId = currentChat.value.id;
const { all, activeIndex, lastIndex } = getConversationParams();
const adjacentConversation =
activeIndex < lastIndex ? all[activeIndex + 1] : all[activeIndex - 1];
const payload = {
conversationId: currentChat.value.id,
conversationId,
status,
snoozedUntil,
};
@@ -95,10 +135,21 @@ const toggleStatus = (status, snoozedUntil, customAttributes = null) => {
payload.customAttributes = customAttributes;
}
store.dispatch('toggleStatus', payload).then(() => {
useAlert(t('CONVERSATION.CHANGE_STATUS'));
isLoading.value = false;
});
store
.dispatch('toggleStatus', payload)
.then(() => {
useAlert(t('CONVERSATION.CHANGE_STATUS'));
if (status !== wootConstants.STATUS_TYPE.OPEN) {
if (adjacentConversation) {
adjacentConversation.click();
} else {
redirectToConversationList();
}
}
})
.finally(() => {
isLoading.value = false;
});
};
const handleResolveWithAttributes = ({ attributes, context }) => {