mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
prevent flicker of message placeholder
This commit is contained in:
parent
2a7d1423e2
commit
b0c97b86f5
@ -69,7 +69,7 @@ export function Conversation({ closeConversation, openDetails, cardId, channelId
|
||||
)}
|
||||
</div>
|
||||
<div class="thread" ref={thread} onScroll={scrollThread}>
|
||||
{ state.topics.length === 0 && (
|
||||
{ state.delayed && state.topics.length === 0 && (
|
||||
<div class="empty">This Topic Has No Messages</div>
|
||||
)}
|
||||
{ state.topics.length !== 0 && (
|
||||
|
@ -24,6 +24,7 @@ export function useConversation(cardId, channelId) {
|
||||
error: false,
|
||||
sealed: false,
|
||||
sealKey: null,
|
||||
delayed: false,
|
||||
});
|
||||
|
||||
const account = useContext(AccountContext);
|
||||
@ -90,7 +91,10 @@ export function useConversation(cardId, channelId) {
|
||||
}, [cardId, channelId, upload]);
|
||||
|
||||
useEffect(() => {
|
||||
updateState({ topics: [] });
|
||||
updateState({ delayed: false, topics: [] });
|
||||
setTimeout(() => {
|
||||
updateState({ delayed: true });
|
||||
}, 250);
|
||||
conversation.actions.setConversationId(cardId, channelId);
|
||||
// eslint-disable-next-line
|
||||
}, [cardId, channelId]);
|
||||
@ -107,6 +111,14 @@ export function useConversation(cardId, channelId) {
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
if (topics.length) {
|
||||
updateState({ delayed: false });
|
||||
}
|
||||
else {
|
||||
setTimeout(() => {
|
||||
updateState({ delayed: true });
|
||||
}, 250);
|
||||
}
|
||||
const { error, loadingInit, loadingMore, subject, logoUrl, logoImg } = conversation.state;
|
||||
updateState({ topics, error, loadingInit, loadingMore, subject, logoUrl, logoImg });
|
||||
store.actions.setValue(`${channelId}::${cardId}`, Number(conversation.state.revision));
|
||||
|
Loading…
Reference in New Issue
Block a user