Refactored Messaging as a part of BOD-14. Breaking changes remain.
This commit is contained in:
@@ -3,18 +3,30 @@ import React from "react";
|
||||
import { CONVERSATION_SUBSCRIPTION_BY_PK } from "../../graphql/conversations.queries";
|
||||
import ChatConversationComponent from "./chat-conversation.component";
|
||||
|
||||
export default function ChatConversationContainer({ conversation }) {
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectSelectedConversation } from "../../redux/messaging/messaging.selectors";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
selectedConversation: selectSelectedConversation,
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, null)(ChatConversationContainer);
|
||||
|
||||
export function ChatConversationContainer({ selectedConversation }) {
|
||||
console.log(
|
||||
"ChatConversationContainer -> selectedConversation",
|
||||
selectedConversation
|
||||
);
|
||||
const { loading, error, data } = useSubscription(
|
||||
CONVERSATION_SUBSCRIPTION_BY_PK,
|
||||
{
|
||||
variables: { conversationId: conversation.id }
|
||||
variables: { conversationId: selectedConversation },
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<ChatConversationComponent
|
||||
subState={[loading, error]}
|
||||
conversation={conversation}
|
||||
unreadCount={
|
||||
(data &&
|
||||
data.conversations_by_pk &&
|
||||
@@ -23,6 +35,14 @@ export default function ChatConversationContainer({ conversation }) {
|
||||
data.conversations_by_pk.messages_aggregate.aggregate.count) ||
|
||||
0
|
||||
}
|
||||
conversation={{
|
||||
conversationId: selectedConversation,
|
||||
phone_num:
|
||||
(data &&
|
||||
data.conversations_by_pk &&
|
||||
data.conversations_by_pk.phone_num) ||
|
||||
"",
|
||||
}}
|
||||
messages={
|
||||
(data &&
|
||||
data.conversations_by_pk &&
|
||||
|
||||
Reference in New Issue
Block a user