From e2e115b80d37418a66c7202f52604a585a19ebc6 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Thu, 14 Apr 2022 22:00:20 -0700 Subject: [PATCH] preparing to pull topics --- net/web/src/App.js | 2 +- net/web/src/AppContext/useAppContext.hook.js | 5 +++-- .../src/User/Conversation/AddTopic/useAddTopic.hook.js | 8 ++++---- .../Channels/ChannelItem/ChannelLabel/ChannelLabel.jsx | 6 +++--- .../ChannelItem/ChannelLabel/useChannelLabel.hook.js | 2 +- .../Channels/ChannelItem/ChannelLogo/ChannelLogo.jsx | 6 +++--- .../ChannelItem/ChannelLogo/useChannelLogo.hook.js | 2 +- .../Contacts/Channels/ChannelItem/useChannelItem.hook.jsx | 2 +- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/net/web/src/App.js b/net/web/src/App.js index 5295d262..cb7a871e 100644 --- a/net/web/src/App.js +++ b/net/web/src/App.js @@ -26,7 +26,7 @@ function App() { }> } /> } /> - } /> + } /> } /> diff --git a/net/web/src/AppContext/useAppContext.hook.js b/net/web/src/AppContext/useAppContext.hook.js index 080b39a5..f18433d7 100644 --- a/net/web/src/AppContext/useAppContext.hook.js +++ b/net/web/src/AppContext/useAppContext.hook.js @@ -228,7 +228,7 @@ export function useAppContext() { updateData({ channels: merged }); } - const getCard = (guid) => { + const getCardByGuid = (guid) => { let card = null; cards.current.forEach((value, key, map) => { if(value?.data?.cardProfile?.guid == guid) { @@ -278,7 +278,8 @@ export function useAppContext() { getRegistry: async (node) => getListing(node), getRegistryImageUrl: (server, guid, revision) => getListingImageUrl(server, guid, revision), getCardImageUrl: (cardId, revision) => getCardImageUrl(state.token, cardId, revision), - getCard: getCard, + getCardByGuid: getCardByGuid, + getCard: (id) => cards.current.get(id), getConnectedCards: getConnectedCards, } diff --git a/net/web/src/User/Conversation/AddTopic/useAddTopic.hook.js b/net/web/src/User/Conversation/AddTopic/useAddTopic.hook.js index 4412ae9a..d242933c 100644 --- a/net/web/src/User/Conversation/AddTopic/useAddTopic.hook.js +++ b/net/web/src/User/Conversation/AddTopic/useAddTopic.hook.js @@ -15,7 +15,7 @@ export function useAddTopic() { busy: false, }); - const { contact, channel } = useParams(); + const { card, channel } = useParams(); const app = useContext(AppContext); const updateState = (value) => { @@ -56,9 +56,9 @@ export function useAddTopic() { try { let message = { text: state.messageText, textColor: state.messageColor, textSize: state.messageSize, backgroundColor: state.backgroundColor }; - if (contact) { - let card = app.actions.getCard(contact); - let token = contact + '.' + card?.data?.cardDetail?.token; + if (card) { + let contact = app.actions.getCard(card); + let token = contact?.data?.cardProfile?.guid + '.' + contact?.data?.cardDetail?.token; await addContactChannelTopic(token, channel, message, []); } else { diff --git a/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLabel/ChannelLabel.jsx b/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLabel/ChannelLabel.jsx index 01474ffb..b5ebf5b6 100644 --- a/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLabel/ChannelLabel.jsx +++ b/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLabel/ChannelLabel.jsx @@ -15,10 +15,10 @@ export function ChannelLabel({ item }) { let contacts = []; if (item?.guid) { - setHost(actions.getCard(item.guid)); + setHost(actions.getCardByGuid(item.guid)); for (let member of item.channel.data.channelDetail.members) { if (member != state.guid) { - contacts.push(actions.getCard(member)); + contacts.push(actions.getCardByGuid(member)); } } setMembers(contacts); @@ -26,7 +26,7 @@ export function ChannelLabel({ item }) { else { setHost(null); for (let member of item.channel.data.channelDetail.members) { - contacts.push(actions.getCard(member)); + contacts.push(actions.getCardByGuid(member)); } setMembers(contacts); } diff --git a/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLabel/useChannelLabel.hook.js b/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLabel/useChannelLabel.hook.js index f04a9061..3a700c93 100644 --- a/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLabel/useChannelLabel.hook.js +++ b/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLabel/useChannelLabel.hook.js @@ -11,7 +11,7 @@ export function useChannelLabel() { const app = useContext(AppContext); const actions = { - getCard: app?.actions?.getCard, + getCardByGuid: app?.actions?.getCardByGuid, }; const updateState = (value) => { diff --git a/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLogo/ChannelLogo.jsx b/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLogo/ChannelLogo.jsx index 749946e9..eec1f494 100644 --- a/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLogo/ChannelLogo.jsx +++ b/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLogo/ChannelLogo.jsx @@ -15,11 +15,11 @@ export function ChannelLogo({ item }) { if (item?.guid) { setHome(false); - setHost(actions.getCard(item.guid)); + setHost(actions.getCardByGuid(item.guid)); let contacts = []; for (let member of item.channel.data.channelDetail.members) { if (member != state.guid) { - contacts.push(actions.getCard(member)); + contacts.push(actions.getCardByGuid(member)); } } setMembers(contacts); @@ -28,7 +28,7 @@ export function ChannelLogo({ item }) { setHome(true); let contacts = []; for (let member of item.channel.data.channelDetail.members) { - contacts.push(actions.getCard(member)); + contacts.push(actions.getCardByGuid(member)); } setMembers(contacts); } diff --git a/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLogo/useChannelLogo.hook.js b/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLogo/useChannelLogo.hook.js index d5f467b5..839852fb 100644 --- a/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLogo/useChannelLogo.hook.js +++ b/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/ChannelLogo/useChannelLogo.hook.js @@ -17,7 +17,7 @@ export function useChannelLogo() { } return null; }, - getCard: app?.actions?.getCard, + getCardByGuid: app?.actions?.getCardByGuid, }; const updateState = (value) => { diff --git a/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/useChannelItem.hook.jsx b/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/useChannelItem.hook.jsx index e5897f1c..729dc26b 100644 --- a/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/useChannelItem.hook.jsx +++ b/net/web/src/User/SideBar/Contacts/Channels/ChannelItem/useChannelItem.hook.jsx @@ -15,7 +15,7 @@ export function useChannelItem() { const actions = { select: (item) => { if (item.guid) { - navigate(`/user/conversation/${item.guid}/${item.channel.id}`); + navigate(`/user/conversation/${item.cardId}/${item.channel.id}`); } else { navigate(`/user/conversation/${item.channel.id}`);