feature/IO-3000-messaging-sockets-migrations2 - Base cleanup
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { CONVERSATION_LIST_QUERY, GET_CONVERSATION_DETAILS } from "../../graphql/conversations.queries";
|
||||
|
||||
export function registerMessagingHandlers({ socket, client }) {
|
||||
export const registerMessagingHandlers = ({ socket, client }) => {
|
||||
if (!(socket && client)) return;
|
||||
function handleNewMessageSummary(message) {
|
||||
|
||||
const handleNewMessageSummary = (message) => {
|
||||
console.log("🚀 ~ SUMMARY CONSOLE LOG:", message);
|
||||
|
||||
if (!message.isoutbound) {
|
||||
@@ -69,9 +70,9 @@ export function registerMessagingHandlers({ socket, client }) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function handleNewMessageDetailed(message) {
|
||||
const handleNewMessageDetailed = (message) => {
|
||||
console.log("🚀 ~ DETAIL CONSOLE LOG:", message);
|
||||
//They're looking at the conversation right now. Need to merge into the list of messages i.e. append to the end.
|
||||
//Add the message to the overall cache.
|
||||
@@ -97,9 +98,9 @@ export function registerMessagingHandlers({ socket, client }) {
|
||||
// We got this as a receive.
|
||||
else {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function handleMessageChanged(message) {
|
||||
const handleMessageChanged = (message) => {
|
||||
//Find it in the cache, and just update it based on what was sent.
|
||||
client.cache.modify({
|
||||
id: client.cache.identify({
|
||||
@@ -114,23 +115,23 @@ export function registerMessagingHandlers({ socket, client }) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function handleConversationChanged(conversation) {
|
||||
const handleConversationChanged = (conversation) => {
|
||||
//If it was archived, marked unread, etc.
|
||||
}
|
||||
};
|
||||
|
||||
socket.on("new-message-summary", handleNewMessageSummary);
|
||||
socket.on("new-message-detailed", handleNewMessageDetailed);
|
||||
socket.on("message-changed", handleMessageChanged);
|
||||
socket.on("conversation-changed", handleConversationChanged); //TODO: Unread, mark as read, archived, unarchive, etc.
|
||||
}
|
||||
socket.on("conversation-changed", handleConversationChanged); //TODO: Unread, mark as read, archived, unarchive, etc.
|
||||
};
|
||||
|
||||
export function unregisterMessagingHandlers({ socket }) {
|
||||
export const unregisterMessagingHandlers = ({ socket }) => {
|
||||
if (!socket) return;
|
||||
socket.off("new-message-summary");
|
||||
socket.off("new-message-detailed");
|
||||
socket.off("message-changed");
|
||||
socket.off("message-changed");
|
||||
socket.off("conversation-changed");
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user