From 918f94ca10c2b55448b25093b0df081b8bce4a16 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Tue, 30 Aug 2022 21:15:13 -0700 Subject: [PATCH] allow for conversation resync --- net/web/src/context/useConversationContext.hook.js | 1 + net/web/src/session/conversation/Conversation.jsx | 13 ++++++++++--- .../src/session/conversation/Conversation.styled.js | 8 ++++++++ .../session/conversation/useConversation.hook.js | 8 ++++++-- .../conversation/virtualList/VirtualList.jsx | 11 +++++++++++ 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/net/web/src/context/useConversationContext.hook.js b/net/web/src/context/useConversationContext.hook.js index 8a238c0f..a5fe9d62 100644 --- a/net/web/src/context/useConversationContext.hook.js +++ b/net/web/src/context/useConversationContext.hook.js @@ -311,6 +311,7 @@ export function useConversationContext() { } }, resync: () => { + updateState({ error: false }); events.current.push({ type: EVENT_RESYNC }); updateConversation(); } diff --git a/net/web/src/session/conversation/Conversation.jsx b/net/web/src/session/conversation/Conversation.jsx index 3f52206b..7c2d16f6 100644 --- a/net/web/src/session/conversation/Conversation.jsx +++ b/net/web/src/session/conversation/Conversation.jsx @@ -1,11 +1,11 @@ -import { ConversationWrapper } from './Conversation.styled'; -import { SettingOutlined, RightOutlined, CloseOutlined } from '@ant-design/icons'; +import { ConversationWrapper, StatusError } from './Conversation.styled'; +import { ExclamationCircleOutlined, SettingOutlined, RightOutlined, CloseOutlined } from '@ant-design/icons'; import { useConversation } from './useConversation.hook'; import { Logo } from 'logo/Logo'; import { AddTopic } from './addTopic/AddTopic'; import { VirtualList } from './virtualList/VirtualList'; import { TopicItem } from './topicItem/TopicItem'; -import { Progress, Spin } from 'antd'; +import { Progress, Spin, Tooltip } from 'antd'; export function Conversation({ closeConversation, openDetails, cardId, channelId }) { @@ -23,6 +23,13 @@ export function Conversation({ closeConversation, openDetails, cardId, channelId
{ state.subject }
+ { state.error && ( + + + + + + )} { state.display !== 'xlarge' && (
diff --git a/net/web/src/session/conversation/Conversation.styled.js b/net/web/src/session/conversation/Conversation.styled.js index 47a23343..d41d67c0 100644 --- a/net/web/src/session/conversation/Conversation.styled.js +++ b/net/web/src/session/conversation/Conversation.styled.js @@ -88,3 +88,11 @@ export const ConversationWrapper = styled.div` flex-shrink: 0; } ` + +export const StatusError = styled.div` + color: ${Colors.error}; + font-size: 14px; + padding-left: 8px; + cursor: pointer; +` + diff --git a/net/web/src/session/conversation/useConversation.hook.js b/net/web/src/session/conversation/useConversation.hook.js index 37210510..814454eb 100644 --- a/net/web/src/session/conversation/useConversation.hook.js +++ b/net/web/src/session/conversation/useConversation.hook.js @@ -19,6 +19,7 @@ export function useConversation(cardId, channelId) { upload: false, uploadError: false, uploadPercent: 0, + error: false, }); const viewport = useContext(ViewportContext); @@ -119,8 +120,8 @@ export function useConversation(cardId, channelId) { } return 1; }); - const { loadingInit, loadingMore } = conversation.state; - updateState({ topics, loadingInit, loadingMore }); + const { error, loadingInit, loadingMore } = conversation.state; + updateState({ topics, error, loadingInit, loadingMore }); store.actions.setValue(`${channelId}::${cardId}`, Number(conversation.state.revision)); }, [conversation]); @@ -129,6 +130,9 @@ export function useConversation(cardId, channelId) { more: () => { conversation.actions.addHistory(); }, + resync: () => { + conversation.actions.resync(); + }, clearUploadError: () => { }, cancelUpload: () => { diff --git a/net/web/src/session/conversation/virtualList/VirtualList.jsx b/net/web/src/session/conversation/virtualList/VirtualList.jsx index 81ea7c00..e4659f99 100644 --- a/net/web/src/session/conversation/virtualList/VirtualList.jsx +++ b/net/web/src/session/conversation/virtualList/VirtualList.jsx @@ -350,6 +350,17 @@ export function VirtualList({ id, items, itemRenderer, loadMore }) { nomore.current = false; }, 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; setScrollPos(e.target.scrollTop); }