mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
rendering header
This commit is contained in:
parent
f2219a3b4e
commit
15f5b83e08
@ -7,6 +7,7 @@ import { AutoSizer, CellMeasurer, CellMeasurerCache, List } from 'react-virtuali
|
|||||||
import { AddTopic } from './AddTopic/AddTopic';
|
import { AddTopic } from './AddTopic/AddTopic';
|
||||||
import { VirtualList } from '../../VirtualList/VirtualList';
|
import { VirtualList } from '../../VirtualList/VirtualList';
|
||||||
import { TopicItem } from './TopicItem/TopicItem';
|
import { TopicItem } from './TopicItem/TopicItem';
|
||||||
|
import { HomeOutlined, DatabaseOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
export function Conversation() {
|
export function Conversation() {
|
||||||
|
|
||||||
@ -16,15 +17,32 @@ export function Conversation() {
|
|||||||
return (<TopicItem topic={topic} />)
|
return (<TopicItem topic={topic} />)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onEdit = () => {
|
||||||
|
console.log("EDIT CONVERSATION");
|
||||||
|
}
|
||||||
|
|
||||||
|
const Icon = () => {
|
||||||
|
if (state.cardId) {
|
||||||
|
return <DatabaseOutlined />
|
||||||
|
}
|
||||||
|
return <HomeOutlined />
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConversationWrapper>
|
<ConversationWrapper>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="title"></div>
|
<div class="title">
|
||||||
<div class="buttons">
|
<Icon />
|
||||||
<ConversationButton ghost onClick={() => actions.remove()}>Remove Conversation</ConversationButton>
|
<div class="subject">{ state.subject }</div>
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
<div class="buttons">
|
||||||
|
<ConversationButton ghost onClick={() => onEdit()}>Members</ConversationButton>
|
||||||
|
<ConversationButton ghost onClick={() => actions.remove()}>Delete</ConversationButton>
|
||||||
|
</div>
|
||||||
|
<CloseButton type="text" class="close" size={'large'}
|
||||||
|
onClick={() => actions.close()} icon={<CloseOutlined />} />
|
||||||
</div>
|
</div>
|
||||||
<CloseButton type="text" class="close" size={'large'}
|
|
||||||
onClick={() => actions.close()} icon={<CloseOutlined />} />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="thread">
|
<div class="thread">
|
||||||
<VirtualList id={state.channelId + state.cardId}
|
<VirtualList id={state.channelId + state.cardId}
|
||||||
|
@ -11,6 +11,7 @@ export const ConversationWrapper = styled.div`
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
|
flex-grow: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@ -22,16 +23,29 @@ export const ConversationWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
height: 64px;
|
|
||||||
flex-grow: 1;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 2em;
|
|
||||||
font-weight: bold;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-shrink: 1;
|
||||||
|
jsutify-content: flex-begin;
|
||||||
|
height: 64px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: flex-begin;
|
|
||||||
color: white;
|
color: white;
|
||||||
|
font-size: 1.5em;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-grow: 1;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subject {
|
||||||
padding-left: 16px;
|
padding-left: 16px;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttons {
|
.buttons {
|
||||||
|
@ -10,6 +10,7 @@ export function useConversation() {
|
|||||||
init: true,
|
init: true,
|
||||||
cardId: null,
|
cardId: null,
|
||||||
channelId: null,
|
channelId: null,
|
||||||
|
subject: null,
|
||||||
topics: [],
|
topics: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ export function useConversation() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateState({
|
updateState({
|
||||||
init: conversation.state.init,
|
init: conversation.state.init,
|
||||||
|
subject: conversation.state.subject,
|
||||||
cardId: conversation.state.cardId,
|
cardId: conversation.state.cardId,
|
||||||
channelId: conversation.state.channelId,
|
channelId: conversation.state.channelId,
|
||||||
topics: Array.from(conversation.state.topics.values()),
|
topics: Array.from(conversation.state.topics.values()),
|
||||||
|
@ -6,6 +6,7 @@ export const UserWrapper = styled.div`
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
background-color: #f6f5ed;
|
background-color: #f6f5ed;
|
||||||
webkit-touch-callout: none;
|
webkit-touch-callout: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
@ -22,6 +23,7 @@ export const UserWrapper = styled.div`
|
|||||||
background-color: #8fbea7;
|
background-color: #8fbea7;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.connect {
|
.connect {
|
||||||
|
@ -220,6 +220,11 @@ export function useCardContext() {
|
|||||||
let node = cardProfile.node;
|
let node = cardProfile.node;
|
||||||
await addContactChannelTopic(node, token, channelId, message, assets);
|
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) => {
|
getChannelRevision: (cardId, channelId) => {
|
||||||
let card = cards.current.get(cardId);
|
let card = cards.current.get(cardId);
|
||||||
let channel = card.channels.get(channelId);
|
let channel = card.channels.get(channelId);
|
||||||
|
@ -95,6 +95,9 @@ export function useChannelContext() {
|
|||||||
addChannelTopic: async (channelId, message, assets) => {
|
addChannelTopic: async (channelId, message, assets) => {
|
||||||
await addChannelTopic(access.current, channelId, message, assets);
|
await addChannelTopic(access.current, channelId, message, assets);
|
||||||
},
|
},
|
||||||
|
getChannel: (channelId) => {
|
||||||
|
return channels.current.get(channelId);
|
||||||
|
},
|
||||||
getChannelRevision: (channelId) => {
|
getChannelRevision: (channelId) => {
|
||||||
let channel = channels.current.get(channelId);
|
let channel = channels.current.get(channelId);
|
||||||
return channel?.revision;
|
return channel?.revision;
|
||||||
|
@ -8,6 +8,7 @@ export function useConversationContext() {
|
|||||||
init: false,
|
init: false,
|
||||||
cardId: null,
|
cardId: null,
|
||||||
channelId: null,
|
channelId: null,
|
||||||
|
subject: null,
|
||||||
topics: new Map(),
|
topics: new Map(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -24,6 +25,29 @@ export function useConversationContext() {
|
|||||||
setState((s) => ({ ...s, ...value }));
|
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 setTopics = async () => {
|
||||||
const { cardId, channelId } = conversationId.current;
|
const { cardId, channelId } = conversationId.current;
|
||||||
const curRevision = revision.current;
|
const curRevision = revision.current;
|
||||||
@ -37,6 +61,8 @@ export function useConversationContext() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (curRevision != deltaRevision) {
|
if (curRevision != deltaRevision) {
|
||||||
|
let conversation = card.actions.getChannel(cardId, channelId);
|
||||||
|
let subject = getSubject(conversation);
|
||||||
let delta = await card.actions.getChannelTopics(cardId, channelId, curRevision);
|
let delta = await card.actions.getChannelTopics(cardId, channelId, curRevision);
|
||||||
for (let topic of delta) {
|
for (let topic of delta) {
|
||||||
if (topic.data == null) {
|
if (topic.data == null) {
|
||||||
@ -65,6 +91,7 @@ export function useConversationContext() {
|
|||||||
if (curView == view.current) {
|
if (curView == view.current) {
|
||||||
updateState({
|
updateState({
|
||||||
init: true,
|
init: true,
|
||||||
|
subject,
|
||||||
topics: topics.current,
|
topics: topics.current,
|
||||||
});
|
});
|
||||||
revision.current = deltaRevision;
|
revision.current = deltaRevision;
|
||||||
@ -77,6 +104,8 @@ export function useConversationContext() {
|
|||||||
else {
|
else {
|
||||||
let deltaRevision = channel.actions.getChannelRevision(channelId);
|
let deltaRevision = channel.actions.getChannelRevision(channelId);
|
||||||
if (curRevision != deltaRevision) {
|
if (curRevision != deltaRevision) {
|
||||||
|
let conversation = channel.actions.getChannel(channelId);
|
||||||
|
let subject = getSubject(conversation);
|
||||||
let delta = await channel.actions.getChannelTopics(channelId, curRevision);
|
let delta = await channel.actions.getChannelTopics(channelId, curRevision);
|
||||||
for (let topic of delta) {
|
for (let topic of delta) {
|
||||||
if (topic.data == null) {
|
if (topic.data == null) {
|
||||||
@ -105,6 +134,7 @@ export function useConversationContext() {
|
|||||||
if (curView == view.current) {
|
if (curView == view.current) {
|
||||||
updateState({
|
updateState({
|
||||||
init: true,
|
init: true,
|
||||||
|
subject,
|
||||||
topics: topics.current,
|
topics: topics.current,
|
||||||
});
|
});
|
||||||
revision.current = deltaRevision;
|
revision.current = deltaRevision;
|
||||||
@ -159,7 +189,7 @@ export function useConversationContext() {
|
|||||||
revision.current = null;
|
revision.current = null;
|
||||||
gone.current = false;
|
gone.current = false;
|
||||||
topics.current = new Map();
|
topics.current = new Map();
|
||||||
updateState({ init: false, cardId, channelId, topics: topics.current });
|
updateState({ init: false, subject: null, cardId, channelId, topics: topics.current });
|
||||||
updateConversation();
|
updateConversation();
|
||||||
},
|
},
|
||||||
getAssetUrl: (topicId, assetId) => {
|
getAssetUrl: (topicId, assetId) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user