diff --git a/client/src/components/chat-affix/registerMessagingSocketHandlers.js b/client/src/components/chat-affix/registerMessagingSocketHandlers.js index c946d3cd4..a6c7cc33a 100644 --- a/client/src/components/chat-affix/registerMessagingSocketHandlers.js +++ b/client/src/components/chat-affix/registerMessagingSocketHandlers.js @@ -346,8 +346,13 @@ export const registerMessagingHandlers = ({ socket, client }) => { client.cache.modify({ id: client.cache.identify({ __typename: "conversations", id: conversationId }), fields: { - job_conversations: (existing = [], { readField }) => - existing.filter((jobRef) => readField("jobid", jobRef) !== fields.jobId) + job_conversations: (existing = [], { readField }) => { + return existing.filter((jobRef) => { + // Read the `jobid` field safely, even if the structure is normalized + const jobId = readField("jobid", jobRef); + return jobId !== fields.jobId; + }); + } } }); break; diff --git a/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx b/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx index 07b48716f..933617cde 100644 --- a/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx +++ b/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx @@ -15,7 +15,7 @@ const mapDispatchToProps = () => ({}); export function ChatConversationTitle({ conversation }) { return ( - + {conversation && conversation.phone_num} diff --git a/client/src/components/chat-messages-list/chat-message-list.styles.scss b/client/src/components/chat-messages-list/chat-message-list.styles.scss index 9ca311ba0..98f5ab8a4 100644 --- a/client/src/components/chat-messages-list/chat-message-list.styles.scss +++ b/client/src/components/chat-messages-list/chat-message-list.styles.scss @@ -8,7 +8,9 @@ height: 20px; border-radius: 4px; } - +.chat-title { + margin-bottom: 5px; +} .messages { display: flex; flex-direction: column; @@ -35,7 +37,11 @@ gap: 8px; } } - +.chat-send-message-button{ + margin: 0.3rem; + padding-left: 0.5rem; + +} .message-icon { position: absolute; bottom: 0.1rem; diff --git a/client/src/components/chat-send-message/chat-send-message.component.jsx b/client/src/components/chat-send-message/chat-send-message.component.jsx index d95bf039b..824d5e591 100644 --- a/client/src/components/chat-send-message/chat-send-message.component.jsx +++ b/client/src/components/chat-send-message/chat-send-message.component.jsx @@ -81,7 +81,7 @@ function ChatSendMessageComponent({ conversation, bodyshop, sendMessage, isSendi /> diff --git a/client/src/utils/GraphQLClient.js b/client/src/utils/GraphQLClient.js index 789bfdf10..c60545f02 100644 --- a/client/src/utils/GraphQLClient.js +++ b/client/src/utils/GraphQLClient.js @@ -145,14 +145,34 @@ middlewares.push( const cache = new InMemoryCache({ typePolicies: { - Query: { + conversations: { fields: { - conversations: offsetLimitPagination() + job_conversations: { + merge(existing = [], incoming = [], { readField }) { + const merged = new Map(); + + // Add existing data to the map + existing.forEach((jobConversation) => { + // Use `readField` to get the unique `jobid`, fallback to `__ref` + const jobId = readField("jobid", jobConversation) || jobConversation.__ref; + if (jobId) merged.set(jobId, jobConversation); + }); + + // Add or replace with incoming data + incoming.forEach((jobConversation) => { + // Use `readField` to get the unique `jobid`, fallback to `__ref` + const jobId = readField("jobid", jobConversation) || jobConversation.__ref; + if (jobId) merged.set(jobId, jobConversation); + }); + + // Return the merged data as an array + return Array.from(merged.values()); + } + } } } } }); - const client = new ApolloClient({ link: ApolloLink.from(middlewares), cache,