mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Checked to ensure tasks has checklists before attempting to sync last checklist item (#8314)
This commit is contained in:
@@ -76,21 +76,23 @@ habitrpg.controller('GroupTasksCtrl', ['$scope', 'Shared', 'Tasks', 'User', func
|
||||
};
|
||||
|
||||
$scope.saveTask = function(task, stayOpen, isSaveAndClose) {
|
||||
// Check if we have a lingering checklist that the enter button did not trigger on
|
||||
var lastIndex = task._edit.checklist.length - 1;
|
||||
var lastCheckListItem = task._edit.checklist[lastIndex];
|
||||
if (lastCheckListItem && !lastCheckListItem.id && lastCheckListItem.text) {
|
||||
Tasks.addChecklistItem(task._id, lastCheckListItem)
|
||||
.then(function (response) {
|
||||
task._edit.checklist[lastIndex] = response.data.data.checklist[lastIndex];
|
||||
task.checklist[lastIndex] = response.data.data.checklist[lastIndex];
|
||||
Tasks.saveTask(task, stayOpen, isSaveAndClose);
|
||||
Tasks.updateTask(task._id, task);
|
||||
});
|
||||
} else {
|
||||
Tasks.saveTask (task, stayOpen, isSaveAndClose);
|
||||
Tasks.updateTask(task._id, task);
|
||||
if (task._edit.checklist) {
|
||||
// Check if we have a lingering checklist that the enter button did not trigger on
|
||||
var lastIndex = task._edit.checklist.length - 1;
|
||||
var lastCheckListItem = task._edit.checklist[lastIndex];
|
||||
if (lastCheckListItem && !lastCheckListItem.id && lastCheckListItem.text) {
|
||||
Tasks.addChecklistItem(task._id, lastCheckListItem)
|
||||
.then(function (response) {
|
||||
task._edit.checklist[lastIndex] = response.data.data.checklist[lastIndex];
|
||||
task.checklist[lastIndex] = response.data.data.checklist[lastIndex];
|
||||
Tasks.saveTask(task, stayOpen, isSaveAndClose);
|
||||
Tasks.updateTask(task._id, task);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
Tasks.saveTask (task, stayOpen, isSaveAndClose);
|
||||
Tasks.updateTask(task._id, task);
|
||||
};
|
||||
|
||||
$scope.shouldShow = function(task, list, prefs){
|
||||
|
||||
Reference in New Issue
Block a user