render upload error

This commit is contained in:
Roland Osborne 2022-09-01 15:17:52 -07:00
parent f51ed1563f
commit 95e6af18b2
4 changed files with 49 additions and 2 deletions

View File

@ -111,6 +111,19 @@ export function useUploadContext() {
cancelContactTopic: (cardId, channelId, topicId) => { cancelContactTopic: (cardId, channelId, topicId) => {
abort(`${cardId}:${channelId}`, topicId); abort(`${cardId}:${channelId}`, topicId);
}, },
clearErrors: (cardId, channelId) => {
const key = cardId ? `${cardId}:${channelId}` : `:${channelId}`;
const topics = channels.current.get(key);
if (topics) {
topics.forEach((topic, topicId) => {
if (topic.error) {
topic.cancel.abort();
topics.delete(topicId);
updateProgress();
}
});
}
},
clear: () => { clear: () => {
channels.current.forEach((topics, channelId) => { channels.current.forEach((topics, channelId) => {
topics.forEach((assets, topicId) => { topics.forEach((assets, topicId) => {

View File

@ -58,7 +58,10 @@ export function Conversation({ closeConversation, openDetails, cardId, channelId
</div> </div>
<div class="divider"> <div class="divider">
<div class="line" /> <div class="line" />
{ state.upload && ( { state.uploadError && (
<div class="progress-error" />
)}
{ state.upload && !state.uploadError && (
<div class="progress-active" style={{ width: state.uploadPercent + '%' }} /> <div class="progress-active" style={{ width: state.uploadPercent + '%' }} />
)} )}
{ !state.upload && ( { !state.upload && (
@ -67,6 +70,17 @@ export function Conversation({ closeConversation, openDetails, cardId, channelId
</div> </div>
<div class="topic"> <div class="topic">
<AddTopic cardId={cardId} channelId={channelId} /> <AddTopic cardId={cardId} channelId={channelId} />
{ state.uploadError && (
<div class="upload-error">
<Tooltip placement="bottom" title="upload error">
<StatusError>
<div onClick={() => actions.clearUploadErrors(cardId, channelId)}>
<ExclamationCircleOutlined />
</div>
</StatusError>
</Tooltip>
</div>
)}
</div> </div>
</ConversationWrapper> </ConversationWrapper>
); );

View File

@ -77,15 +77,34 @@ export const ConversationWrapper = styled.div`
.progress-idle { .progress-idle {
border-top: 1px solid ${Colors.divider}; border-top: 1px solid ${Colors.divider};
height: 1px;
} }
.progress-active { .progress-active {
border-top: 1px solid ${Colors.primary}; border-top: 1px solid ${Colors.primary};
height: 1px;
}
.progress-error {
border-top: 1px solid ${Colors.alert};
width: 100%;
height: 1px;
display: flex;
justify-content: flex-end;
} }
} }
.topic { .topic {
flex-shrink: 0; flex-shrink: 0;
position: relative;
.upload-error {
position: absolute;
top: 0;
right: 0;
margin-right: 16px;
cursor-pointer;
}
} }
` `

View File

@ -133,7 +133,8 @@ export function useConversation(cardId, channelId) {
resync: () => { resync: () => {
conversation.actions.resync(); conversation.actions.resync();
}, },
clearUploadError: () => { clearUploadErrors: (cardId, channelId) => {
upload.actions.clearErrors(cardId, channelId);
}, },
cancelUpload: () => { cancelUpload: () => {
}, },