allow for conversation resync

This commit is contained in:
Roland Osborne 2022-08-30 21:15:13 -07:00
parent 0726a47be9
commit 918f94ca10
5 changed files with 36 additions and 5 deletions

View File

@ -311,6 +311,7 @@ export function useConversationContext() {
} }
}, },
resync: () => { resync: () => {
updateState({ error: false });
events.current.push({ type: EVENT_RESYNC }); events.current.push({ type: EVENT_RESYNC });
updateConversation(); updateConversation();
} }

View File

@ -1,11 +1,11 @@
import { ConversationWrapper } from './Conversation.styled'; import { ConversationWrapper, StatusError } from './Conversation.styled';
import { SettingOutlined, RightOutlined, CloseOutlined } from '@ant-design/icons'; import { ExclamationCircleOutlined, SettingOutlined, RightOutlined, CloseOutlined } from '@ant-design/icons';
import { useConversation } from './useConversation.hook'; import { useConversation } from './useConversation.hook';
import { Logo } from 'logo/Logo'; import { Logo } from 'logo/Logo';
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 { Progress, Spin } from 'antd'; import { Progress, Spin, Tooltip } from 'antd';
export function Conversation({ closeConversation, openDetails, cardId, channelId }) { export function Conversation({ closeConversation, openDetails, cardId, channelId }) {
@ -23,6 +23,13 @@ export function Conversation({ closeConversation, openDetails, cardId, channelId
<Logo img={state.image} url={state.logo} width={32} height={32} radius={4} /> <Logo img={state.image} url={state.logo} width={32} height={32} radius={4} />
</div> </div>
<div class="label">{ state.subject }</div> <div class="label">{ state.subject }</div>
{ state.error && (
<Tooltip placement="bottom" title="sync error">
<StatusError onClick={actions.resync}>
<ExclamationCircleOutlined />
</StatusError>
</Tooltip>
)}
{ state.display !== 'xlarge' && ( { state.display !== 'xlarge' && (
<div class="button" onClick={openDetails}> <div class="button" onClick={openDetails}>
<SettingOutlined /> <SettingOutlined />

View File

@ -88,3 +88,11 @@ export const ConversationWrapper = styled.div`
flex-shrink: 0; flex-shrink: 0;
} }
` `
export const StatusError = styled.div`
color: ${Colors.error};
font-size: 14px;
padding-left: 8px;
cursor: pointer;
`

View File

@ -19,6 +19,7 @@ export function useConversation(cardId, channelId) {
upload: false, upload: false,
uploadError: false, uploadError: false,
uploadPercent: 0, uploadPercent: 0,
error: false,
}); });
const viewport = useContext(ViewportContext); const viewport = useContext(ViewportContext);
@ -119,8 +120,8 @@ export function useConversation(cardId, channelId) {
} }
return 1; return 1;
}); });
const { loadingInit, loadingMore } = conversation.state; const { error, loadingInit, loadingMore } = conversation.state;
updateState({ topics, loadingInit, loadingMore }); updateState({ topics, error, loadingInit, loadingMore });
store.actions.setValue(`${channelId}::${cardId}`, Number(conversation.state.revision)); store.actions.setValue(`${channelId}::${cardId}`, Number(conversation.state.revision));
}, [conversation]); }, [conversation]);
@ -129,6 +130,9 @@ export function useConversation(cardId, channelId) {
more: () => { more: () => {
conversation.actions.addHistory(); conversation.actions.addHistory();
}, },
resync: () => {
conversation.actions.resync();
},
clearUploadError: () => { clearUploadError: () => {
}, },
cancelUpload: () => { cancelUpload: () => {

View File

@ -350,6 +350,17 @@ export function VirtualList({ id, items, itemRenderer, loadMore }) {
nomore.current = false; nomore.current = false;
}, moreDelay); }, moreDelay);
} }
if (scrollTop.current > e.target.scrollTop) {
const len = containers.current.length;
const last = containers.current[len-1];
if (len > 0) {
if (e.target.scrollTop + state.listHeight < last.top) {
actions.unlatch();
}
}
}
scrollTop.current = e.target.scrollTop; scrollTop.current = e.target.scrollTop;
setScrollPos(e.target.scrollTop); setScrollPos(e.target.scrollTop);
} }