if (new_version != lists_version)
window.setTimeout(load_lists);
}
+function got_list_version(new_version) {
+ var id_data = selected_list.data('id');
+ if (new_version != id_data.version)
+ window.setTimeout(() => load_list_items(id_data.uri, selected_list));
+}
function load_list_items(uri, target) {
$.get(uri)
.done(item_data => {
return false;
}
function new_list_item_submission_done(data) {
- if (data.lists_version != lists_version) {
- load_lists();
- return;
- }
+ got_list_version(data.list_version);
var item_data = selected_list.data('items');
- if (data.list_version != item_data.version + 1) {
- load_list_items(current_list);
- }
- else {
var new_item = {
description: $('#new-list-item input[type="text"]').val().trim(),
done: $('#new-list-item input[type="checkbox"]').prop('checked'),
item_data.items.push(new_item);
item_data.version = data.list_version;
add_list_item(new_item);
- }
$('#new-list-item input').val('');
}