Extracted the list building on the events screen to a separate method, updated the firebase function to handle updates on the "done" field in tasks

This commit is contained in:
Mariano Uvalle 2019-04-27 19:24:56 -05:00
parent dfe52b77ef
commit 09555aeadf
3 changed files with 23 additions and 14 deletions

View file

@ -121,6 +121,11 @@ export const pendingTasksUpdater: functions.CloudFunction<functions.Change<Fireb
await incrementPendingTasks(eventDocument, decrementValue);
break;
case 'update':
if (before.get('done') !== after.get('done')) {
const value = after.get('done') ? decrementValue : incrementValue;
await incrementFromPriority(after.get('priority'), eventDocument, userDocument, value);
await incrementPendingTasks(eventDocument, value);
}
if (before.get('priority') !== after.get('priority')) {
await incrementFromPriority(before.get('priority'), eventDocumentBefore!, userDocument, decrementValue);
await incrementFromPriority(after.get('priority'), eventDocument, userDocument, incrementValue);