Update to make history delete and pin function call to new APIs

This commit is contained in:
Wu Cheng-Han 2016-10-10 21:00:07 +08:00
parent 7a46c9fc5c
commit 68457ed3a2

View file

@ -166,6 +166,18 @@ function parseHistoryCallback(list, notehistory) {
pinned = false; pinned = false;
item._values.pinned = false; item._values.pinned = false;
} }
checkIfAuth(function () {
postHistoryToServer(id, {
pinned: pinned
}, function (err, result) {
if (!err) {
if (pinned)
$this.addClass('active');
else
$this.removeClass('active');
}
});
}, function () {
getHistory(function (notehistory) { getHistory(function (notehistory) {
for(var i = 0; i < notehistory.length; i++) { for(var i = 0; i < notehistory.length; i++) {
if (notehistory[i].id == id) { if (notehistory[i].id == id) {
@ -179,6 +191,7 @@ function parseHistoryCallback(list, notehistory) {
else else
$this.removeClass('active'); $this.removeClass('active');
}); });
})
}); });
buildTagsFilter(filtertags); buildTagsFilter(filtertags);
} }
@ -199,6 +212,22 @@ var clearHistory = false;
var deleteId = null; var deleteId = null;
function deleteHistory() { function deleteHistory() {
checkIfAuth(function () {
deleteServerHistory(deleteId, function (err, result) {
if (!err) {
if (clearHistory) {
historyList.clear();
checkHistoryList();
} else {
historyList.remove('id', deleteId);
checkHistoryList();
}
}
$('.delete-modal').modal('hide');
deleteId = null;
clearHistory = false;
});
}, function () {
if (clearHistory) { if (clearHistory) {
saveHistory([]); saveHistory([]);
historyList.clear(); historyList.clear();
@ -216,6 +245,7 @@ function deleteHistory() {
} }
$('.delete-modal').modal('hide'); $('.delete-modal').modal('hide');
clearHistory = false; clearHistory = false;
});
} }
$(".ui-delete-modal-confirm").click(function () { $(".ui-delete-modal-confirm").click(function () {