36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import { useSubscription } from "@apollo/react-hooks";
|
|
import React from "react";
|
|
import { CONVERSATION_SUBSCRIPTION_BY_PK } from "../../graphql/conversations.queries";
|
|
import ChatConversationComponent from "./chat-conversation.component";
|
|
|
|
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: selectedConversation },
|
|
}
|
|
);
|
|
|
|
return (
|
|
<ChatConversationComponent
|
|
subState={[loading, error]}
|
|
conversation={data ? data.conversations_by_pk : {}}
|
|
|
|
|
|
/>
|
|
);
|
|
}
|