From 15f5b83e088afec7d25fea2f8df26a6bd7bcafc7 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Fri, 13 May 2022 00:15:15 -0700 Subject: [PATCH] rendering header --- .../src/User/Conversation/Conversation.jsx | 28 +++++++++++++--- .../User/Conversation/Conversation.styled.jsx | 26 +++++++++++---- .../User/Conversation/useConversation.hook.js | 2 ++ net/web/src/User/User.styled.js | 2 ++ net/web/src/context/useCardContext.hook.js | 5 +++ net/web/src/context/useChannelContext.hook.js | 3 ++ .../context/useConversationContext.hook.js | 32 ++++++++++++++++++- 7 files changed, 86 insertions(+), 12 deletions(-) diff --git a/net/web/src/User/Conversation/Conversation.jsx b/net/web/src/User/Conversation/Conversation.jsx index 276205a0..5038276a 100644 --- a/net/web/src/User/Conversation/Conversation.jsx +++ b/net/web/src/User/Conversation/Conversation.jsx @@ -7,6 +7,7 @@ import { AutoSizer, CellMeasurer, CellMeasurerCache, List } from 'react-virtuali import { AddTopic } from './AddTopic/AddTopic'; import { VirtualList } from '../../VirtualList/VirtualList'; import { TopicItem } from './TopicItem/TopicItem'; +import { HomeOutlined, DatabaseOutlined } from '@ant-design/icons'; export function Conversation() { @@ -16,15 +17,32 @@ export function Conversation() { return () } + const onEdit = () => { + console.log("EDIT CONVERSATION"); + } + + const Icon = () => { + if (state.cardId) { + return + } + return + } + return (
-
-
- actions.remove()}>Remove Conversation +
+ +
{ state.subject }
+
+
+
+ onEdit()}>Members + actions.remove()}>Delete +
+ actions.close()} icon={} />
- actions.close()} icon={} />
{ updateState({ init: conversation.state.init, + subject: conversation.state.subject, cardId: conversation.state.cardId, channelId: conversation.state.channelId, topics: Array.from(conversation.state.topics.values()), diff --git a/net/web/src/User/User.styled.js b/net/web/src/User/User.styled.js index 68e66c37..2ca975cf 100644 --- a/net/web/src/User/User.styled.js +++ b/net/web/src/User/User.styled.js @@ -6,6 +6,7 @@ export const UserWrapper = styled.div` flex-direction: row; width: 100%; height: 100%; + overflow: hidden; background-color: #f6f5ed; webkit-touch-callout: none; -webkit-user-select: none; @@ -22,6 +23,7 @@ export const UserWrapper = styled.div` background-color: #8fbea7; align-items: center; justify-content: center; + min-width: 0; } .connect { diff --git a/net/web/src/context/useCardContext.hook.js b/net/web/src/context/useCardContext.hook.js index 8fb24569..d7e99244 100644 --- a/net/web/src/context/useCardContext.hook.js +++ b/net/web/src/context/useCardContext.hook.js @@ -220,6 +220,11 @@ export function useCardContext() { let node = cardProfile.node; await addContactChannelTopic(node, token, channelId, message, assets); }, + getChannel: (cardId, channelId) => { + let card = cards.current.get(cardId); + let channel = card.channels.get(channelId); + return channel; + }, getChannelRevision: (cardId, channelId) => { let card = cards.current.get(cardId); let channel = card.channels.get(channelId); diff --git a/net/web/src/context/useChannelContext.hook.js b/net/web/src/context/useChannelContext.hook.js index 538c1ce2..31c77287 100644 --- a/net/web/src/context/useChannelContext.hook.js +++ b/net/web/src/context/useChannelContext.hook.js @@ -95,6 +95,9 @@ export function useChannelContext() { addChannelTopic: async (channelId, message, assets) => { await addChannelTopic(access.current, channelId, message, assets); }, + getChannel: (channelId) => { + return channels.current.get(channelId); + }, getChannelRevision: (channelId) => { let channel = channels.current.get(channelId); return channel?.revision; diff --git a/net/web/src/context/useConversationContext.hook.js b/net/web/src/context/useConversationContext.hook.js index 1270dcf4..7c6b8de1 100644 --- a/net/web/src/context/useConversationContext.hook.js +++ b/net/web/src/context/useConversationContext.hook.js @@ -8,6 +8,7 @@ export function useConversationContext() { init: false, cardId: null, channelId: null, + subject: null, topics: new Map(), }); @@ -24,6 +25,29 @@ export function useConversationContext() { setState((s) => ({ ...s, ...value })); } + const getSubject = (conversation) => { + try { + let subject = JSON.parse(conversation.data.channelDetail.data).subject; + if (subject) { + return subject; + } + } + catch (err) { + console.log(err); + } + let members = []; + if (conversation.guid) { + members.push(card.actions.getCardByGuid(conversation.guid)?.data?.cardProfile?.handle); + } + for (let member of conversation.data.channelDetail.members) { + let contact = card.actions.getCardByGuid(member) + if(contact?.data?.cardProfile?.handle) { + members.push(contact?.data?.cardProfile?.handle); + } + } + return members.join(', '); + } + const setTopics = async () => { const { cardId, channelId } = conversationId.current; const curRevision = revision.current; @@ -37,6 +61,8 @@ export function useConversationContext() { return; } if (curRevision != deltaRevision) { + let conversation = card.actions.getChannel(cardId, channelId); + let subject = getSubject(conversation); let delta = await card.actions.getChannelTopics(cardId, channelId, curRevision); for (let topic of delta) { if (topic.data == null) { @@ -65,6 +91,7 @@ export function useConversationContext() { if (curView == view.current) { updateState({ init: true, + subject, topics: topics.current, }); revision.current = deltaRevision; @@ -77,6 +104,8 @@ export function useConversationContext() { else { let deltaRevision = channel.actions.getChannelRevision(channelId); if (curRevision != deltaRevision) { + let conversation = channel.actions.getChannel(channelId); + let subject = getSubject(conversation); let delta = await channel.actions.getChannelTopics(channelId, curRevision); for (let topic of delta) { if (topic.data == null) { @@ -105,6 +134,7 @@ export function useConversationContext() { if (curView == view.current) { updateState({ init: true, + subject, topics: topics.current, }); revision.current = deltaRevision; @@ -159,7 +189,7 @@ export function useConversationContext() { revision.current = null; gone.current = false; topics.current = new Map(); - updateState({ init: false, cardId, channelId, topics: topics.current }); + updateState({ init: false, subject: null, cardId, channelId, topics: topics.current }); updateConversation(); }, getAssetUrl: (topicId, assetId) => {