mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
more conversation refactor
This commit is contained in:
parent
d0ee4a7515
commit
86d0e31fa7
@ -10,6 +10,7 @@ const Colors = {
|
|||||||
mask: '#dddddd',
|
mask: '#dddddd',
|
||||||
encircle: '#cccccc',
|
encircle: '#cccccc',
|
||||||
alert: '#ff8888',
|
alert: '#ff8888',
|
||||||
|
warn: '#dd4444',
|
||||||
enabled: '#444444',
|
enabled: '#444444',
|
||||||
disabled: '#aaaaaa',
|
disabled: '#aaaaaa',
|
||||||
text: '#444444',
|
text: '#444444',
|
||||||
|
@ -15,7 +15,7 @@ export function Conversation({ closeConversation, openDetails, cardId, channelId
|
|||||||
const thread = useRef(null);
|
const thread = useRef(null);
|
||||||
|
|
||||||
const topicRenderer = (topic) => {
|
const topicRenderer = (topic) => {
|
||||||
return (<TopicItem host={cardId == null} topic={topic} />)
|
return (<TopicItem host={cardId == null} topic={topic} remove={() => actions.removeTopic(topic.id)}/>)
|
||||||
}
|
}
|
||||||
|
|
||||||
// an unfortunate cludge for the mobile browser
|
// an unfortunate cludge for the mobile browser
|
||||||
|
@ -7,7 +7,32 @@ import { Space, Skeleton, Button, Modal, Input } from 'antd';
|
|||||||
import { ExclamationCircleOutlined, DeleteOutlined, EditOutlined, FireOutlined, PictureOutlined } from '@ant-design/icons';
|
import { ExclamationCircleOutlined, DeleteOutlined, EditOutlined, FireOutlined, PictureOutlined } from '@ant-design/icons';
|
||||||
import { Carousel } from 'carousel/Carousel';
|
import { Carousel } from 'carousel/Carousel';
|
||||||
|
|
||||||
export function TopicItem({ host, topic }) {
|
export function TopicItem({ host, topic, remove }) {
|
||||||
|
|
||||||
|
const [ modal, modalContext ] = Modal.useModal();
|
||||||
|
|
||||||
|
const removeTopic = () => {
|
||||||
|
modal.confirm({
|
||||||
|
title: 'Do you want to delete this message?',
|
||||||
|
icon: <ExclamationCircleOutlined />,
|
||||||
|
bodyStyle: { padding: 16 },
|
||||||
|
okText: 'Yes, Delete',
|
||||||
|
cancelText: 'No, Cancel',
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
await remove();
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
console.log(err);
|
||||||
|
modal.error({
|
||||||
|
title: 'Failed to Delete Message',
|
||||||
|
content: 'Please try again.',
|
||||||
|
bodyStyle: { padding: 16 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const renderAsset = (asset, idx) => {
|
const renderAsset = (asset, idx) => {
|
||||||
if (asset.image) {
|
if (asset.image) {
|
||||||
@ -26,6 +51,7 @@ export function TopicItem({ host, topic }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<TopicItemWrapper>
|
<TopicItemWrapper>
|
||||||
|
{ modalContext }
|
||||||
<div class="topic-header">
|
<div class="topic-header">
|
||||||
<div class="avatar">
|
<div class="avatar">
|
||||||
<Logo width={32} height={32} radius={4} url={topic.imageUrl} />
|
<Logo width={32} height={32} radius={4} url={topic.imageUrl} />
|
||||||
@ -34,6 +60,20 @@ export function TopicItem({ host, topic }) {
|
|||||||
<div class={ topic.nameSet ? 'set' : 'unset' }>{ topic.name }</div>
|
<div class={ topic.nameSet ? 'set' : 'unset' }>{ topic.name }</div>
|
||||||
<div>{ topic.createdStr }</div>
|
<div>{ topic.createdStr }</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="topic-options">
|
||||||
|
<div class="buttons">
|
||||||
|
{ topic.creator && (
|
||||||
|
<div class="button edit" onClick={() => console.log('edit')}>
|
||||||
|
<EditOutlined />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{ (host || topic.creator) && (
|
||||||
|
<div class="button remove" onClick={removeTopic}>
|
||||||
|
<DeleteOutlined />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{ topic.status !== 'confirmed' && (
|
{ topic.status !== 'confirmed' && (
|
||||||
<div class="skeleton">
|
<div class="skeleton">
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import Colors from 'constants/Colors';
|
||||||
|
|
||||||
export const TopicItemWrapper = styled.div`
|
export const TopicItemWrapper = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -18,10 +19,6 @@ export const TopicItemWrapper = styled.div`
|
|||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover .info {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.topic-options {
|
.topic-options {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
padding-left: 16px;
|
padding-left: 16px;
|
||||||
@ -33,7 +30,6 @@ export const TopicItemWrapper = styled.div`
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background-color: #eeeeee;
|
background-color: #eeeeee;
|
||||||
border: 1px solid #555555;
|
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
@ -42,6 +38,14 @@ export const TopicItemWrapper = styled.div`
|
|||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.remove {
|
||||||
|
color: ${Colors.warn};
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit {
|
||||||
|
color: ${Colors.primary};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,10 +10,6 @@ export function VideoAsset({ thumbUrl, lqUrl, hdUrl }) {
|
|||||||
const { state, actions } = useVideoAsset();
|
const { state, actions } = useVideoAsset();
|
||||||
const [dimension, setDimension] = useState({ width: 0, height: 0 });
|
const [dimension, setDimension] = useState({ width: 0, height: 0 });
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log(dimension);
|
|
||||||
}, [dimension]);
|
|
||||||
|
|
||||||
const activate = () => {
|
const activate = () => {
|
||||||
if (dimension.width / dimension.height > window.innerWidth / window.innerHeight) {
|
if (dimension.width / dimension.height > window.innerWidth / window.innerHeight) {
|
||||||
let width = Math.floor(window.innerWidth * 8 / 10);
|
let width = Math.floor(window.innerWidth * 8 / 10);
|
||||||
|
@ -210,12 +210,15 @@ export function useConversation(cardId, channelId) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const messages = new Map();
|
const messages = new Map();
|
||||||
conversation.state.topics.forEach((value, id) => {
|
conversation.state.topics.forEach((value, id) => {
|
||||||
let item = topics.current.get(id);
|
const curCardId = conversation.state.card?.id;
|
||||||
|
const curChannelId = conversation.state.channel?.id;
|
||||||
|
const key = `${curCardId}:${curChannelId}:${id}`
|
||||||
|
let item = topics.current.get(key);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
item = { id };
|
item = { id };
|
||||||
}
|
}
|
||||||
syncTopic(item, value);
|
syncTopic(item, value);
|
||||||
messages.set(id, item);
|
messages.set(key, item);
|
||||||
});
|
});
|
||||||
topics.current = messages;
|
topics.current = messages;
|
||||||
|
|
||||||
@ -245,6 +248,9 @@ export function useConversation(cardId, channelId) {
|
|||||||
},
|
},
|
||||||
cancelUpload: () => {
|
cancelUpload: () => {
|
||||||
},
|
},
|
||||||
|
removeTopic: async (topicId) => {
|
||||||
|
await conversation.actions.removeTopic(topicId);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return { state, actions };
|
return { state, actions };
|
||||||
|
@ -15,10 +15,10 @@ export const IdentityWrapper = styled.div`
|
|||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
background-color: ${Colors.formFocus};
|
||||||
|
|
||||||
.drop {
|
.drop {
|
||||||
border: 1px solid ${Colors.encircle};
|
font-weight: bold;
|
||||||
background-color: ${Colors.formHover};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user