[apply-toast-shared-notes] - error messages wait until user closes them and added timeout to toast
This commit is contained in:
parent
dea0e498c7
commit
d7c5ab3623
@ -17,10 +17,10 @@ export default function setPresentationRenderedInToast() {
|
|||||||
const numberAffected = Presentations.update({
|
const numberAffected = Presentations.update({
|
||||||
renderedInToast: false,
|
renderedInToast: false,
|
||||||
meetingId,
|
meetingId,
|
||||||
}, payload);
|
}, payload, {multi: true});
|
||||||
|
|
||||||
if (numberAffected) {
|
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) {
|
} catch (err) {
|
||||||
Logger.error(`Exception while invoking method setPresentationRenderedInToast ${err.stack}`);
|
Logger.error(`Exception while invoking method setPresentationRenderedInToast ${err.stack}`);
|
||||||
|
@ -8,6 +8,8 @@ import { toast } from 'react-toastify';
|
|||||||
import { defineMessages } from 'react-intl';
|
import { defineMessages } from 'react-intl';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { UploadingPresentations } from '/imports/api/presentations';
|
import { UploadingPresentations } from '/imports/api/presentations';
|
||||||
|
|
||||||
|
const TIMEOUT_CLOSE_TOAST = 1; //second
|
||||||
|
|
||||||
const intlMessages = defineMessages({
|
const intlMessages = defineMessages({
|
||||||
|
|
||||||
@ -289,13 +291,26 @@ export const ToastController = ({ intl }) => {
|
|||||||
const uploadingPresentations = UploadingPresentations.find().fetch();
|
const uploadingPresentations = UploadingPresentations.find().fetch();
|
||||||
let presentationsToConvert = convertingPresentations.concat(uploadingPresentations);
|
let presentationsToConvert = convertingPresentations.concat(uploadingPresentations);
|
||||||
|
|
||||||
presentationsToConvert.map(p => {return {temporaryPresentationId: p.temporaryPresentationId, presentationId: p.id}}).forEach(objectId => {
|
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))})
|
||||||
if (!alreadyRenderedPresList.some(pres => (pres.temporaryPresentationId === objectId.temporaryPresentationId || pres.presentationId === objectId.presentationId))){
|
// 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({
|
alreadyRenderedPresList.push({
|
||||||
temporaryPresentationId: objectId.temporaryPresentationId,
|
temporaryPresentationId: objectId.temporaryPresentationId,
|
||||||
presentationId: objectId.presentationId,
|
presentationId: objectId.presentationId,
|
||||||
rendered: false,
|
rendered: false,
|
||||||
|
hasError: objectId.hasError,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
alreadyRenderedPresList[docIndexAlreadyInList].hasError = objectId.hasError;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let activeToast = Session.get("presentationUploaderToastId");
|
let activeToast = Session.get("presentationUploaderToastId");
|
||||||
@ -309,6 +324,10 @@ export const ToastController = ({ intl }) => {
|
|||||||
onClose: () => {
|
onClose: () => {
|
||||||
Session.set("presentationUploaderToastId", null);
|
Session.set("presentationUploaderToastId", null);
|
||||||
presentationsToConvert = [];
|
presentationsToConvert = [];
|
||||||
|
if (alreadyRenderedPresList.every((pres) => pres.rendered)) {
|
||||||
|
makeCall('setPresentationRenderedInToast');
|
||||||
|
alreadyRenderedPresList.length = 0;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
Session.set("presentationUploaderToastId", activeToast);
|
Session.set("presentationUploaderToastId", activeToast);
|
||||||
@ -332,9 +351,12 @@ export const ToastController = ({ intl }) => {
|
|||||||
return p.temporaryPresentationId
|
return p.temporaryPresentationId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (alreadyRenderedPresList.every((pres) => pres.rendered)) {
|
if (alreadyRenderedPresList.every((pres) => pres.rendered && !pres.hasError)) {
|
||||||
makeCall('setPresentationRenderedInToast');
|
|
||||||
alreadyRenderedPresList.length = 0;
|
setTimeout(() => {
|
||||||
|
makeCall('setPresentationRenderedInToast');
|
||||||
|
alreadyRenderedPresList.length = 0;
|
||||||
|
}, TIMEOUT_CLOSE_TOAST * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [])
|
}, [])
|
||||||
|
@ -105,7 +105,7 @@ const observePresentationConversion = (
|
|||||||
if (doc.temporaryPresentationId !== temporaryPresentationId && doc.id !== tokenId) return;
|
if (doc.temporaryPresentationId !== temporaryPresentationId && doc.id !== tokenId) return;
|
||||||
|
|
||||||
if (doc.conversion.status === 'FILE_TOO_LARGE' || doc.conversion.status === 'UNSUPPORTED_DOCUMENT') {
|
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);
|
onConversion(doc.conversion);
|
||||||
c.stop();
|
c.stop();
|
||||||
clearTimeout(conversionTimeout);
|
clearTimeout(conversionTimeout);
|
||||||
|
Loading…
Reference in New Issue
Block a user