mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +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) {
|
$scope.saveTask = function(task, stayOpen, isSaveAndClose) {
|
||||||
// Check if we have a lingering checklist that the enter button did not trigger on
|
if (task._edit.checklist) {
|
||||||
var lastIndex = task._edit.checklist.length - 1;
|
// Check if we have a lingering checklist that the enter button did not trigger on
|
||||||
var lastCheckListItem = task._edit.checklist[lastIndex];
|
var lastIndex = task._edit.checklist.length - 1;
|
||||||
if (lastCheckListItem && !lastCheckListItem.id && lastCheckListItem.text) {
|
var lastCheckListItem = task._edit.checklist[lastIndex];
|
||||||
Tasks.addChecklistItem(task._id, lastCheckListItem)
|
if (lastCheckListItem && !lastCheckListItem.id && lastCheckListItem.text) {
|
||||||
.then(function (response) {
|
Tasks.addChecklistItem(task._id, lastCheckListItem)
|
||||||
task._edit.checklist[lastIndex] = response.data.data.checklist[lastIndex];
|
.then(function (response) {
|
||||||
task.checklist[lastIndex] = response.data.data.checklist[lastIndex];
|
task._edit.checklist[lastIndex] = response.data.data.checklist[lastIndex];
|
||||||
Tasks.saveTask(task, stayOpen, isSaveAndClose);
|
task.checklist[lastIndex] = response.data.data.checklist[lastIndex];
|
||||||
Tasks.updateTask(task._id, task);
|
Tasks.saveTask(task, stayOpen, isSaveAndClose);
|
||||||
});
|
Tasks.updateTask(task._id, task);
|
||||||
} else {
|
});
|
||||||
Tasks.saveTask (task, stayOpen, isSaveAndClose);
|
return;
|
||||||
Tasks.updateTask(task._id, task);
|
}
|
||||||
}
|
}
|
||||||
|
Tasks.saveTask (task, stayOpen, isSaveAndClose);
|
||||||
|
Tasks.updateTask(task._id, task);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.shouldShow = function(task, list, prefs){
|
$scope.shouldShow = function(task, list, prefs){
|
||||||
|
|||||||
Reference in New Issue
Block a user