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({
|
client.cache.modify({
|
||||||
id: client.cache.identify({ __typename: "conversations", id: conversationId }),
|
id: client.cache.identify({ __typename: "conversations", id: conversationId }),
|
||||||
fields: {
|
fields: {
|
||||||
job_conversations: (existing = [], { readField }) =>
|
job_conversations: (existing = [], { readField }) => {
|
||||||
existing.filter((jobRef) => readField("jobid", jobRef) !== fields.jobId)
|
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;
|
break;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const mapDispatchToProps = () => ({});
|
|||||||
|
|
||||||
export function ChatConversationTitle({ conversation }) {
|
export function ChatConversationTitle({ conversation }) {
|
||||||
return (
|
return (
|
||||||
<Space wrap>
|
<Space className="chat-title" wrap>
|
||||||
<PhoneNumberFormatter>{conversation && conversation.phone_num}</PhoneNumberFormatter>
|
<PhoneNumberFormatter>{conversation && conversation.phone_num}</PhoneNumberFormatter>
|
||||||
<ChatLabelComponent conversation={conversation} />
|
<ChatLabelComponent conversation={conversation} />
|
||||||
<ChatPrintButton conversation={conversation} />
|
<ChatPrintButton conversation={conversation} />
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
height: 20px;
|
height: 20px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
.chat-title {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
.messages {
|
.messages {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -35,7 +37,11 @@
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.chat-send-message-button{
|
||||||
|
margin: 0.3rem;
|
||||||
|
padding-left: 0.5rem;
|
||||||
|
|
||||||
|
}
|
||||||
.message-icon {
|
.message-icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0.1rem;
|
bottom: 0.1rem;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ function ChatSendMessageComponent({ conversation, bodyshop, sendMessage, isSendi
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<SendOutlined
|
<SendOutlined
|
||||||
className="imex-flex-row__margin"
|
className="chat-send-message-button"
|
||||||
// disabled={message === "" || !message}
|
// disabled={message === "" || !message}
|
||||||
onClick={handleEnter}
|
onClick={handleEnter}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -145,14 +145,34 @@ middlewares.push(
|
|||||||
|
|
||||||
const cache = new InMemoryCache({
|
const cache = new InMemoryCache({
|
||||||
typePolicies: {
|
typePolicies: {
|
||||||
Query: {
|
conversations: {
|
||||||
fields: {
|
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({
|
const client = new ApolloClient({
|
||||||
link: ApolloLink.from(middlewares),
|
link: ApolloLink.from(middlewares),
|
||||||
cache,
|
cache,
|
||||||
|
|||||||
Reference in New Issue
Block a user