[apply-toast-shared-notes] - error messages wait until user closes them and added timeout to toast

This commit is contained in:
GuiLeme 2022-09-16 17:36:23 -03:00
parent dea0e498c7
commit d7c5ab3623
3 changed files with 30 additions and 8 deletions

View File

@ -17,10 +17,10 @@ export default function setPresentationRenderedInToast() {
const numberAffected = Presentations.update({
renderedInToast: false,
meetingId,
}, payload);
}, payload, {multi: true});
if (numberAffected) {
Logger.info(`Presentations have been set as rendered in the toast within meeting=${meetingId}`);
Logger.info(`Presentations have been set as rendered in the toast within meeting=${meetingId}, ${numberAffected} documents affected.`);
}
} catch (err) {
Logger.error(`Exception while invoking method setPresentationRenderedInToast ${err.stack}`);

View File

@ -9,6 +9,8 @@ import { defineMessages } from 'react-intl';
import _ from 'lodash';
import { UploadingPresentations } from '/imports/api/presentations';
const TIMEOUT_CLOSE_TOAST = 1; //second
const intlMessages = defineMessages({
item: {
@ -289,13 +291,26 @@ export const ToastController = ({ intl }) => {
const uploadingPresentations = UploadingPresentations.find().fetch();
let presentationsToConvert = convertingPresentations.concat(uploadingPresentations);
presentationsToConvert.map(p => {return {temporaryPresentationId: p.temporaryPresentationId, presentationId: p.id}}).forEach(objectId => {
if (!alreadyRenderedPresList.some(pres => (pres.temporaryPresentationId === objectId.temporaryPresentationId || pres.presentationId === objectId.presentationId))){
console.log("Teste pra saber quais são as presentations: -------> ", {presentationsToConvert: JSON.parse(JSON.stringify(presentationsToConvert)), alreadyRenderedPresList: JSON.parse(JSON.stringify(alreadyRenderedPresList)), presentationsRenderedFalseAndConversionFalse: JSON.parse(JSON.stringify(presentationsRenderedFalseAndConversionFalse))})
// Updating or populating the "state" presentation list
presentationsToConvert.map(p => {
return {
temporaryPresentationId: p.temporaryPresentationId,
presentationId: p.id,
hasError: p.conversion?.error || p.upload?.error,
}
}).forEach(objectId => {
const docIndexAlreadyInList = alreadyRenderedPresList.findIndex(pres => (pres.temporaryPresentationId === objectId.temporaryPresentationId || pres.presentationId === objectId.presentationId))
if (docIndexAlreadyInList === -1) {
alreadyRenderedPresList.push({
temporaryPresentationId: objectId.temporaryPresentationId,
presentationId: objectId.presentationId,
rendered: false,
hasError: objectId.hasError,
});
} else {
alreadyRenderedPresList[docIndexAlreadyInList].hasError = objectId.hasError;
}
})
let activeToast = Session.get("presentationUploaderToastId");
@ -309,6 +324,10 @@ export const ToastController = ({ intl }) => {
onClose: () => {
Session.set("presentationUploaderToastId", null);
presentationsToConvert = [];
if (alreadyRenderedPresList.every((pres) => pres.rendered)) {
makeCall('setPresentationRenderedInToast');
alreadyRenderedPresList.length = 0;
}
},
});
Session.set("presentationUploaderToastId", activeToast);
@ -332,9 +351,12 @@ export const ToastController = ({ intl }) => {
return p.temporaryPresentationId
});
if (alreadyRenderedPresList.every((pres) => pres.rendered)) {
if (alreadyRenderedPresList.every((pres) => pres.rendered && !pres.hasError)) {
setTimeout(() => {
makeCall('setPresentationRenderedInToast');
alreadyRenderedPresList.length = 0;
}, TIMEOUT_CLOSE_TOAST * 1000);
}
}, [])

View File

@ -105,7 +105,7 @@ const observePresentationConversion = (
if (doc.temporaryPresentationId !== temporaryPresentationId && doc.id !== tokenId) return;
if (doc.conversion.status === 'FILE_TOO_LARGE' || doc.conversion.status === 'UNSUPPORTED_DOCUMENT') {
Presentations.update({id: tokenId}, {$set: {temporaryPresentationId}})
Presentations.update({id: tokenId}, {$set: {temporaryPresentationId, renderedInToast: false}})
onConversion(doc.conversion);
c.stop();
clearTimeout(conversionTimeout);