[apply-toast-shared-notes] Checkpoint - moving responsability of monitoring the upload to the service

This commit is contained in:
GuiLeme 2022-07-26 09:25:36 -03:00
parent 82e0204cfa
commit f0c95c4fe5
2 changed files with 37 additions and 8 deletions

View File

@ -327,15 +327,15 @@ class PresentationUploader extends Component {
const toastId = Session.get("presentationUploaderToastId");
if (toastId) {
if (!prevProps.isOpen && isOpen) {
this.props.handleDismissToast(toastId);
}
// if (toastId) {
// if (!prevProps.isOpen && isOpen) {
// this.props.handleDismissToast(toastId);
// }
toast.update(toastId, {
render: this.props.renderToastList(this.state.presentations, this.state.toUploadCount, intl),
});
}
// toast.update(toastId, {
// render: this.props.renderToastList(this.state.presentations, this.state.toUploadCount, intl),
// });
// }
}
componentWillUnmount() {

View File

@ -417,6 +417,34 @@ function renderToastItem(item, intl) {
);
}
const verifyUploadToast = (presentations, toUploadCount, intl) => {
const toastId = Session.get("presentationUploaderToastId");
if (toastId) {
toast.update(toastId, {
render: renderToastList(presentations, toUploadCount, intl),
});
}
}
const observePresentationsForToast = (meetingId, presentations, toUploadCount, intl) => new Promise((resolve, reject) => {
Tracker.autorun((c) => {
const query = Presentations.find({ meetingId });
query.observe({
added: (doc) => {
console.log(presentations)
verifyUploadToast(presentations, toUploadCount, intl)
},
changed: (newDoc) => {
console.log(presentations)
verifyUploadToast(presentations, toUploadCount, intl)
},
});
});
})
function handleDismissToast(toastId) {
return toast.dismiss(toastId);
}
@ -499,6 +527,7 @@ const persistPresentationChanges = (oldState, newState, uploadEndpoint, podId, t
},
});
Session.set('presentationUploaderToastId', toastId)
observePresentationsForToast(Auth.meetingID, presentationsToUpload, toUploadCount, intl)
}
const presentationsToRemove = oldState.filter((p) => !_.find(newState, ['id', p.id]));