[apply-toast-shared-notes] Checkpoint - moving responsability of monitoring the upload to the service
This commit is contained in:
parent
82e0204cfa
commit
f0c95c4fe5
@ -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() {
|
||||
|
@ -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]));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user