rendering upload progress

This commit is contained in:
Roland Osborne 2022-08-24 11:48:28 -07:00
parent 0501884708
commit 9db4c93602
14 changed files with 72 additions and 12 deletions

View File

@ -31,6 +31,7 @@ export function useUploadContext() {
upload: entry.index, upload: entry.index,
topicId: topic, topicId: topic,
active: entry.active, active: entry.active,
uploaded: entry.assets.length,
index: entry.assets.length + active, index: entry.assets.length + active,
count: entry.assets.length + entry.files.length + active, count: entry.assets.length + entry.files.length + active,
error: entry.error, error: entry.error,

View File

@ -35,7 +35,7 @@ export const AccountWrapper = styled.div`
.content { .content {
min-height: 0; min-height: 0;
width: 100%; width: 100%;
overflow: scroll; overflow: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;

View File

@ -10,7 +10,7 @@ export const CardsWrapper = styled.div`
.view { .view {
min-height: 0; min-height: 0;
overflow: scroll; overflow: auto;
flex-grow: 1; flex-grow: 1;
} }

View File

@ -10,7 +10,7 @@ export const ChannelsWrapper = styled.div`
.view { .view {
min-height: 0; min-height: 0;
overflow: scroll; overflow: auto;
flex-grow: 1; flex-grow: 1;
} }

View File

@ -18,7 +18,7 @@ export const AddChannelWrapper = styled.div`
width: 100%; width: 100%;
min-height: 100px; min-height: 100px;
max-height: 200px; max-height: 200px;
overflow: scroll; overflow: auto;
border: 1px solid ${Colors.divider}; border: 1px solid ${Colors.divider};
} }
`; `;

View File

@ -37,7 +37,7 @@ export const ContactWrapper = styled.div`
.content { .content {
min-height: 0; min-height: 0;
width: 100%; width: 100%;
overflow: scroll; overflow: auto;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
@ -92,7 +92,7 @@ export const ContactWrapper = styled.div`
.view { .view {
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: scroll; overflow: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;

View File

@ -5,6 +5,7 @@ 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 } from 'antd';
export function Conversation({ closeConversation, openDetails, cardId, channelId }) { export function Conversation({ closeConversation, openDetails, cardId, channelId }) {
@ -40,6 +41,12 @@ export function Conversation({ closeConversation, openDetails, cardId, channelId
</div> </div>
<div class="divider"> <div class="divider">
<div class="line" /> <div class="line" />
{ state.upload && (
<div class="progress-active" style={{ width: state.uploadPercent + '%' }} />
)}
{ !state.upload && (
<div class="progress-idle" />
)}
</div> </div>
<div class="topic"> <div class="topic">
<AddTopic cardId={cardId} channelId={channelId} /> <AddTopic cardId={cardId} channelId={channelId} />

View File

@ -62,6 +62,14 @@ export const ConversationWrapper = styled.div`
.line { .line {
border-top: 1px solid ${Colors.divider}; border-top: 1px solid ${Colors.divider};
} }
.progress-idle {
border-top: 1px solid ${Colors.divider};
}
.progress-active {
border-top: 1px solid ${Colors.primary};
}
} }
.topic { .topic {

View File

@ -5,6 +5,10 @@ export const TopicItemWrapper = styled.div`
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
&:hover .options {
visibility: visible;
}
.topic-header { .topic-header {
display: flex; display: flex;
flex-direction: row; flex-direction: row;

View File

@ -3,6 +3,7 @@ import { ViewportContext } from 'context/ViewportContext';
import { CardContext } from 'context/CardContext'; import { CardContext } from 'context/CardContext';
import { ChannelContext } from 'context/ChannelContext'; import { ChannelContext } from 'context/ChannelContext';
import { ConversationContext } from 'context/ConversationContext'; import { ConversationContext } from 'context/ConversationContext';
import { UploadContext } from 'context/UploadContext';
export function useConversation(cardId, channelId) { export function useConversation(cardId, channelId) {
@ -12,12 +13,16 @@ export function useConversation(cardId, channelId) {
logo: null, logo: null,
subject: null, subject: null,
topics: [], topics: [],
upload: false,
uploadError: false,
uploadPercent: 0,
}); });
const viewport = useContext(ViewportContext); const viewport = useContext(ViewportContext);
const card = useContext(CardContext); const card = useContext(CardContext);
const channel = useContext(ChannelContext); const channel = useContext(ChannelContext);
const conversation = useContext(ConversationContext); const conversation = useContext(ConversationContext);
const upload = useContext(UploadContext);
const updateState = (value) => { const updateState = (value) => {
setState((s) => ({ ...s, ...value })); setState((s) => ({ ...s, ...value }));
@ -27,6 +32,38 @@ export function useConversation(cardId, channelId) {
updateState({ display: viewport.state.display }); updateState({ display: viewport.state.display });
}, [viewport]); }, [viewport]);
useEffect(() => {
let active = false;
let uploadError = false;
let uploadPercent = 0;
let uploadIndex = 0;
let uploadCount = 0;
let uploadActive = { loaded: 0, total: 0 };
let uploadActiveCount = 0;
const progress = upload.state.progress.get(`${cardId ? cardId : ''}:${channelId}`);
if (progress) {
progress.forEach((entry) => {
active = true;
if (entry.error) {
uploadError = true;
}
uploadIndex += entry.uploaded;
uploadCount += entry.count;
if (entry.active) {
uploadActiveCount += 1;
uploadActive.loaded += entry.active.loaded;
uploadActive.total += entry.active.total;
}
});
uploadPercent = (uploadIndex + (uploadActiveCount * (uploadActive.loaded / uploadActive.total)) / uploadCount);
uploadPercent = Math.floor(uploadPercent * 100);
}
updateState({ upload: active, uploadError, uploadPercent });
}, [cardId, channelId, upload]);
useEffect(() => { useEffect(() => {
let chan, image, subject, logo; let chan, image, subject, logo;
@ -85,6 +122,10 @@ export function useConversation(cardId, channelId) {
more: () => { more: () => {
conversation.actions.addHistory(); conversation.actions.addHistory();
}, },
clearUploadError: () => {
},
cancelUpload: () => {
},
}; };
return { state, actions }; return { state, actions };

View File

@ -35,7 +35,7 @@ export const DetailsWrapper = styled.div`
.content { .content {
min-height: 0; min-height: 0;
width: 100%; width: 100%;
overflow: scroll; overflow: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-top: 32px; padding-top: 32px;
@ -43,7 +43,6 @@ export const DetailsWrapper = styled.div`
flex-grow: 1; flex-grow: 1;
position: relative; position: relative;
min-height: 0; min-height: 0;
overflow: scroll;
.label { .label {
padding-top: 16px; padding-top: 16px;

View File

@ -11,7 +11,7 @@ export const EditMembersWrapper = styled.div`
width: 100%; width: 100%;
min-height: 100px; min-height: 100px;
max-height: 200px; max-height: 200px;
overflow: scroll; overflow: auto;
border: 1px solid ${Colors.divider}; border: 1px solid ${Colors.divider};
} }

View File

@ -10,7 +10,7 @@ export const ListingWrapper = styled.div`
.view { .view {
min-height: 0; min-height: 0;
overflow: scroll; overflow: auto;
flex-grow: 1; flex-grow: 1;
} }

View File

@ -36,7 +36,7 @@ export const ProfileWrapper = styled.div`
.content { .content {
min-height: 0; min-height: 0;
width: 100%; width: 100%;
overflow: scroll; overflow: auto;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
@ -125,7 +125,7 @@ export const ProfileWrapper = styled.div`
.view { .view {
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: scroll; overflow: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;