feature/IO-3000-messaging-sockets-migration2 -
- Various work Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -15,7 +15,7 @@ const mapDispatchToProps = () => ({});
|
||||
|
||||
export function ChatConversationTitle({ conversation }) {
|
||||
return (
|
||||
<Space wrap>
|
||||
<Space className="chat-title" wrap>
|
||||
<PhoneNumberFormatter>{conversation && conversation.phone_num}</PhoneNumberFormatter>
|
||||
<ChatLabelComponent conversation={conversation} />
|
||||
<ChatPrintButton conversation={conversation} />
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -81,7 +81,7 @@ function ChatSendMessageComponent({ conversation, bodyshop, sendMessage, isSendi
|
||||
/>
|
||||
</span>
|
||||
<SendOutlined
|
||||
className="imex-flex-row__margin"
|
||||
className="chat-send-message-button"
|
||||
// disabled={message === "" || !message}
|
||||
onClick={handleEnter}
|
||||
/>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user