diff --git a/app/livechat/server/lib/Contacts.js b/app/livechat/server/lib/Contacts.js
index 7e0f94e10d7..5e8b70aaf69 100644
--- a/app/livechat/server/lib/Contacts.js
+++ b/app/livechat/server/lib/Contacts.js
@@ -4,6 +4,10 @@ import s from 'underscore.string';
import {
LivechatVisitors,
LivechatCustomField,
+ LivechatRooms,
+ Rooms,
+ LivechatInquiry,
+ Subscriptions,
} from '../../../models';
@@ -60,6 +64,15 @@ export const Contacts = {
LivechatVisitors.updateById(contactId, updateUser);
+ const rooms = LivechatRooms.findByVisitorId(contactId).fetch();
+
+ rooms?.length && rooms.forEach((room) => {
+ const { _id: rid } = room;
+ Rooms.setFnameById(rid, name)
+ && LivechatInquiry.setNameByRoomId(rid, name)
+ && Subscriptions.updateDisplayNameByRoomId(rid, name);
+ });
+
return contactId;
},
};
diff --git a/client/views/omnichannel/directory/chats/contextualBar/RoomEdit.js b/client/views/omnichannel/directory/chats/contextualBar/RoomEdit.js
index e5efb2eab4c..76046859457 100644
--- a/client/views/omnichannel/directory/chats/contextualBar/RoomEdit.js
+++ b/client/views/omnichannel/directory/chats/contextualBar/RoomEdit.js
@@ -16,10 +16,6 @@ import { useForm } from '../../../../../hooks/useForm';
import { formsSubscription } from '../../../additionalForms';
import { FormSkeleton } from '../../Skeleton';
-const initialValuesUser = {
- name: '',
-};
-
const initialValuesRoom = {
topic: '',
tags: [],
@@ -27,18 +23,6 @@ const initialValuesRoom = {
priorityId: '',
};
-const getInitialValuesUser = (visitor) => {
- if (!visitor) {
- return initialValuesUser;
- }
-
- const { name, fname } = visitor;
-
- return {
- name: (name || fname) ?? '',
- };
-};
-
const getInitialValuesRoom = (room) => {
if (!room) {
return initialValuesRoom;
@@ -57,9 +41,6 @@ const getInitialValuesRoom = (room) => {
function RoomEdit({ room, visitor, reload, close }) {
const t = useTranslation();
- const { values, handlers, hasUnsavedChanges: hasUnsavedChangesContact } = useForm(
- getInitialValuesUser(visitor),
- );
const {
values: valuesRoom,
handlers: handlersRoom,
@@ -68,9 +49,6 @@ function RoomEdit({ room, visitor, reload, close }) {
const canViewCustomFields = () =>
hasAtLeastOnePermission(['view-livechat-room-customfields', 'edit-livechat-room-customfields']);
- const { handleName } = handlers;
- const { name } = values;
-
const { handleTopic, handleTags, handlePriorityId } = handlersRoom;
const { topic, tags, priorityId } = valuesRoom;
@@ -131,7 +109,6 @@ function RoomEdit({ room, visitor, reload, close }) {
e.preventDefault();
const userData = {
_id: visitor._id,
- name,
};
const roomData = {
@@ -153,8 +130,7 @@ function RoomEdit({ room, visitor, reload, close }) {
});
const formIsValid =
- (hasUnsavedChangesContact || hasUnsavedChangesRoom || hasUnsavedChangesCustomFields) &&
- customFieldsError.length === 0;
+ (hasUnsavedChangesRoom || hasUnsavedChangesCustomFields) && customFieldsError.length === 0;
if ([stateCustomFields, statePriorities].includes(AsyncStatePhase.LOADING)) {
return ;
@@ -165,12 +141,6 @@ function RoomEdit({ room, visitor, reload, close }) {
return (
<>
-
- {t('Name')}
-
-
-
-
{canViewCustomFields() && allCustomFields && (