parent
2dcd197f85
commit
a25ee114bb
2 changed files with 67 additions and 0 deletions
|
|
@ -246,6 +246,20 @@ ListModel {
|
|||
})
|
||||
}
|
||||
|
||||
function updateNote(note, callback) {
|
||||
var ttrss = rootWindow.getTTRSS()
|
||||
var index = root.selectedIndex
|
||||
var item = getSelectedItem()
|
||||
|
||||
ttrss.updateFeedNote(item.id, note, function(successful, errorMessage) {
|
||||
if (successful) {
|
||||
root.setProperty(index, "note", note)
|
||||
}
|
||||
|
||||
callback(successful, errorMessage)
|
||||
})
|
||||
}
|
||||
|
||||
function getLabels(callback) {
|
||||
var ttrss = rootWindow.getTTRSS()
|
||||
var item = getSelectedItem()
|
||||
|
|
|
|||
|
|
@ -913,6 +913,59 @@ function process_updateFeedUnread(callback, httpreq) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update articles' notes.
|
||||
* @param {int} The ids of the articles.
|
||||
* @param {string} The note.
|
||||
* @param {function} A callback function with parameters boolean (indicating
|
||||
* success) and string (an optional error message).
|
||||
*/
|
||||
function updateFeedNote(articleIds, note, callback) {
|
||||
if(responsesPending['feeditemnote']) {
|
||||
return;
|
||||
}
|
||||
|
||||
// needs to be logged in
|
||||
if(!state['token']) {
|
||||
requestsPending['feeditemnote'] = true;
|
||||
processPendingRequests(callback);
|
||||
return;
|
||||
}
|
||||
|
||||
responsesPending['feeditemnote'] = true;
|
||||
|
||||
var params = {
|
||||
'op': 'updateArticle',
|
||||
'sid': state['token'],
|
||||
'article_ids': articleIds,
|
||||
'field': 3,
|
||||
'data': note
|
||||
}
|
||||
|
||||
networkCall(params, function(http) { process_updateFeedNote(callback, http) });
|
||||
}
|
||||
|
||||
/** @private */
|
||||
function process_updateFeedNote(callback, httpreq) {
|
||||
var response = process_readyState(httpreq);
|
||||
|
||||
responsesPending['feeditemnote'] = false;
|
||||
|
||||
if (!response.successful) {
|
||||
trace(1, "Update feeditem note: " + response.errorMessage);
|
||||
if (callback) {
|
||||
callback(false, response.errorMessage);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!processPendingRequests(callback) && callback) {
|
||||
// This action is complete (as there's no other requests to do)
|
||||
// Fire callback saying all ok
|
||||
callback(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of configured labels.
|
||||
* @param {int} The id of an arbitrary article.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue