From 6e611fbc7cedd7d7ff640661addef0b859cafa60 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Thu, 27 Aug 2020 14:41:25 -0700 Subject: [PATCH] Dynamically show messaging based on presence of msid BOD-322 --- .../chat-affix/chat-affix.container.jsx | 43 +++++++++++++------ client/src/pages/profile/profile.page.jsx | 2 +- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/client/src/components/chat-affix/chat-affix.container.jsx b/client/src/components/chat-affix/chat-affix.container.jsx index 6b6db1ecd..15c270650 100644 --- a/client/src/components/chat-affix/chat-affix.container.jsx +++ b/client/src/components/chat-affix/chat-affix.container.jsx @@ -6,27 +6,42 @@ import LoadingSpinner from "../loading-spinner/loading-spinner.component"; import ChatAffixComponent from "./chat-affix.component"; import { Affix } from "antd"; import "./chat-affix.styles.scss"; -export default function ChatAffixContainer() { + +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); + +export function ChatAffixContainer({ bodyshop }) { const { loading, error, data } = useSubscription( - CONVERSATION_LIST_SUBSCRIPTION + CONVERSATION_LIST_SUBSCRIPTION, + { + skip: !bodyshop || (bodyshop && !bodyshop.messagingservicesid), + } ); + if (loading) return ; - if (error) return ; + if (error) return ; return ( - +
- { - return (acc = acc + val.messages_aggregate.aggregate.count); - }, 0)) || - 0 - } - /> + {bodyshop && bodyshop.messagingservicesid ? ( + { + return (acc = acc + val.messages_aggregate.aggregate.count); + }, 0)) || + 0 + } + /> + ) : null}
); } +export default connect(mapStateToProps, null)(ChatAffixContainer); diff --git a/client/src/pages/profile/profile.page.jsx b/client/src/pages/profile/profile.page.jsx index f8d576d77..d4525eebb 100644 --- a/client/src/pages/profile/profile.page.jsx +++ b/client/src/pages/profile/profile.page.jsx @@ -6,7 +6,7 @@ export default function ProfilePage() { return (
- ; +
); }