Use error() more consistently
parent
8df835ca72
commit
762e17021a
|
@ -167,9 +167,11 @@ Page {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
serverPage.server.uploadArticle(
|
serverPage.server.uploadArticle(
|
||||||
addArticleUrl.text,
|
addArticleUrl.text,
|
||||||
function() {
|
function( success ) {
|
||||||
addArticleUrl.text = ""
|
if ( success ) {
|
||||||
hideAddArticleContainer.start()
|
addArticleUrl.text = ""
|
||||||
|
hideAddArticleContainer.start()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -249,10 +251,11 @@ Page {
|
||||||
articlesModel.remove( idx )
|
articlesModel.remove( idx )
|
||||||
serverPage.server.deleteArticle(
|
serverPage.server.deleteArticle(
|
||||||
id,
|
id,
|
||||||
function( err ) {
|
function( success ) {
|
||||||
if ( err !== null ) {
|
if ( !success ) {
|
||||||
showError( err )
|
showError( err )
|
||||||
// Just reload the whole list. May be inefficient though
|
// Reload the whole list, it's simpler than re-adding
|
||||||
|
// the removed article in the right place.
|
||||||
serverPage.updateArticlesList()
|
serverPage.updateArticlesList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,15 +282,10 @@ Page {
|
||||||
|
|
||||||
serverPage.server.toggleArticleStar(
|
serverPage.server.toggleArticleStar(
|
||||||
model,
|
model,
|
||||||
function( star, err ) {
|
function( success ) {
|
||||||
articleMenu.hide()
|
articleMenu.hide()
|
||||||
|
if ( success )
|
||||||
if ( err !== null ) {
|
|
||||||
showError( err )
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
serverPage.updateArticlesList()
|
serverPage.updateArticlesList()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -302,15 +300,10 @@ Page {
|
||||||
|
|
||||||
serverPage.server.toggleArticleRead(
|
serverPage.server.toggleArticleRead(
|
||||||
model,
|
model,
|
||||||
function( read, err ) {
|
function( success ) {
|
||||||
articleMenu.hide()
|
articleMenu.hide()
|
||||||
|
if ( success )
|
||||||
if ( err !== null ) {
|
|
||||||
showError( err )
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
serverPage.updateArticlesList()
|
serverPage.updateArticlesList()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,8 @@ Item {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No need for a callback here as the articlesDownloaded() signal will
|
||||||
|
// be emitted if there are any changes.
|
||||||
function getUpdatedArticles() {
|
function getUpdatedArticles() {
|
||||||
connect(
|
connect(
|
||||||
function( err ) {
|
function( err ) {
|
||||||
|
@ -173,12 +175,20 @@ Item {
|
||||||
connect(
|
connect(
|
||||||
function( err ) {
|
function( err ) {
|
||||||
if ( err !== null ) {
|
if ( err !== null ) {
|
||||||
error( qsTr( "Failed to connect to server: " ) + err)
|
error( qsTr( "Failed to connect to server: " ) + err )
|
||||||
|
cb( false )
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.debug( "Sending a new article" )
|
console.debug( "Sending a new article" )
|
||||||
var props = { url: url, token: accessToken }
|
var props = { url: url, token: accessToken }
|
||||||
WallaBase.uploadNewArticle( props, articleUrl, function( content, err ) { onUploadArticleDone( content, err ); cb(); } )
|
WallaBase.uploadNewArticle(
|
||||||
|
props,
|
||||||
|
articleUrl,
|
||||||
|
function( content, err ) {
|
||||||
|
onUploadArticleDone( content, err )
|
||||||
|
cb( err === null )
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -215,7 +225,8 @@ Item {
|
||||||
connect(
|
connect(
|
||||||
function( err ) {
|
function( err ) {
|
||||||
if ( err !== null ) {
|
if ( err !== null ) {
|
||||||
cb( null, qsTr( "Failed to connect to server: " ) + err );
|
error( qsTr( "Failed to connect to server: " ) + err );
|
||||||
|
cb( false )
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var articleUrl = url
|
var articleUrl = url
|
||||||
|
@ -233,7 +244,8 @@ Item {
|
||||||
accessToken,
|
accessToken,
|
||||||
JSON.stringify( json ),
|
JSON.stringify( json ),
|
||||||
function( patchResponse, patchError ) {
|
function( patchResponse, patchError ) {
|
||||||
onToggleArticleStarDone( patchResponse, patchError, article, cb )
|
onToggleArticleStarDone( patchResponse, patchError, article )
|
||||||
|
cb( patchError === null )
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -241,15 +253,14 @@ Item {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onToggleArticleStarDone( content, err, article, cb ) {
|
function onToggleArticleStarDone( content, err, article ) {
|
||||||
if ( err !== null ) {
|
if ( err !== null ) {
|
||||||
cb( null, qsTr( "Failed to set star status on article: " ) + err )
|
error( qsTr( "Failed to set star status on article: " ) + err )
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.debug( "Done toggling starred status for article " + article.id )
|
console.debug( "Done toggling starred status for article " + article.id )
|
||||||
var json = JSON.parse( content )
|
var json = JSON.parse( content )
|
||||||
WallaBase.setArticleStar( serverId, article.id, json.is_starred )
|
WallaBase.setArticleStar( serverId, article.id, json.is_starred )
|
||||||
cb( json.is_starred, null )
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +268,8 @@ Item {
|
||||||
connect(
|
connect(
|
||||||
function( err ) {
|
function( err ) {
|
||||||
if ( err !== null ) {
|
if ( err !== null ) {
|
||||||
cb( null, qsTr( "Failed to connect to server: " ) + err )
|
error( qsTr( "Failed to connect to server: " ) + err )
|
||||||
|
cb( false )
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var articleUrl = url
|
var articleUrl = url
|
||||||
|
@ -275,7 +287,8 @@ Item {
|
||||||
accessToken,
|
accessToken,
|
||||||
JSON.stringify( json ),
|
JSON.stringify( json ),
|
||||||
function( patchResponse, patchError ) {
|
function( patchResponse, patchError ) {
|
||||||
onToggleArticleReadDone( patchResponse, patchError, article, cb )
|
onToggleArticleReadDone( patchResponse, patchError, article )
|
||||||
|
cb( patchError === null )
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -285,13 +298,12 @@ Item {
|
||||||
|
|
||||||
function onToggleArticleReadDone( content, err, article, cb ) {
|
function onToggleArticleReadDone( content, err, article, cb ) {
|
||||||
if ( err !== null ) {
|
if ( err !== null ) {
|
||||||
cb( null, qsTr( "Failed to set read status on article: " ) + err )
|
error( qsTr( "Failed to set read status on article: " ) + err )
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.debug( "Done toggling archived status for article " + article.id )
|
console.debug( "Done toggling archived status for article " + article.id )
|
||||||
var json = JSON.parse( content )
|
var json = JSON.parse( content )
|
||||||
WallaBase.setArticleRead( serverId, article.id, json.is_archived )
|
WallaBase.setArticleRead( serverId, article.id, json.is_archived )
|
||||||
cb( json.is_archived, null )
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +311,8 @@ Item {
|
||||||
connect(
|
connect(
|
||||||
function( err ) {
|
function( err ) {
|
||||||
if ( err !== null ) {
|
if ( err !== null ) {
|
||||||
cb( qsTr( "Failed to connect to server: " ) + err )
|
error( qsTr( "Failed to connect to server: " ) + err )
|
||||||
|
cb( false )
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var articleUrl = url
|
var articleUrl = url
|
||||||
|
@ -313,7 +326,8 @@ Item {
|
||||||
articleUrl,
|
articleUrl,
|
||||||
accessToken,
|
accessToken,
|
||||||
function( delResponse, delError ) {
|
function( delResponse, delError ) {
|
||||||
onDeleteArticleDone( delResponse, delError, id, cb )
|
onDeleteArticleDone( delResponse, delError, id )
|
||||||
|
cb( err === null )
|
||||||
}
|
}
|
||||||
|
|
||||||
)
|
)
|
||||||
|
@ -324,12 +338,11 @@ Item {
|
||||||
|
|
||||||
function onDeleteArticleDone( content, err, id, cb ) {
|
function onDeleteArticleDone( content, err, id, cb ) {
|
||||||
if ( err !== null ) {
|
if ( err !== null ) {
|
||||||
cb( qsTr( "Failed to delete article: " ) + err )
|
error( qsTr( "Failed to delete article: " ) + err )
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.debug( "Done deleting article " + id )
|
console.debug( "Done deleting article " + id )
|
||||||
WallaBase.deleteArticle( serverId, id )
|
WallaBase.deleteArticle( serverId, id )
|
||||||
cb( null )
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue