Offer an option to prevent downloading archived articles
parent
115d52f94a
commit
11e665b137
|
@ -95,7 +95,7 @@ function getServer( id, cb )
|
|||
function( tx ) {
|
||||
var server = null;
|
||||
try {
|
||||
var res = tx.executeSql( "SELECT id, name, url, lastSync FROM servers WHERE id=?", [ id ] );
|
||||
var res = tx.executeSql( "SELECT id, name, url, lastSync, fetchUnread FROM servers WHERE id=?", [ id ] );
|
||||
if ( res.rows.length === 0 ) {
|
||||
err = qsTr( "Server not found in the configuration" );
|
||||
}
|
||||
|
@ -145,14 +145,15 @@ function addNewServer( props )
|
|||
db.transaction(
|
||||
function( tx ) {
|
||||
// TODO: try/catch here when error management is in place in the UI
|
||||
tx.executeSql( "INSERT INTO servers(name, url, user, password, clientId, clientSecret) VALUES(?, ?, ?, ?, ?, ?)",
|
||||
tx.executeSql( "INSERT INTO servers(name, url, user, password, clientId, clientSecret, fetchUnread) VALUES(?, ?, ?, ?, ?, ?, ?)",
|
||||
[
|
||||
props.name,
|
||||
props.url,
|
||||
props.user,
|
||||
props.password,
|
||||
props.clientId,
|
||||
props.clientSecret
|
||||
props.clientSecret,
|
||||
props.fetchUnread ? 1 : 0
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -172,7 +173,8 @@ function updateServer( id, props )
|
|||
"user=?, " +
|
||||
"password=?, " +
|
||||
"clientId=?, " +
|
||||
"clientSecret=? " +
|
||||
"clientSecret=?, " +
|
||||
"fetchUnread=? " +
|
||||
"WHERE id=?",
|
||||
[
|
||||
props.name,
|
||||
|
@ -181,6 +183,7 @@ function updateServer( id, props )
|
|||
props.password,
|
||||
props.clientId,
|
||||
props.clientSecret,
|
||||
props.fetchUnread ? 1 : 0,
|
||||
id
|
||||
]
|
||||
);
|
||||
|
@ -587,6 +590,9 @@ function downloadArticles( props, cb )
|
|||
url += "/";
|
||||
url += "api/entries.json";
|
||||
url += "?since=" + props.since;
|
||||
// We only use the archive flag to filter out read articles
|
||||
if ( 'archive' in props && props.archive === 0 )
|
||||
url += '&archive=' + props.archive
|
||||
url += "&perPage=10";
|
||||
|
||||
var articles = new Array;
|
||||
|
@ -805,9 +811,14 @@ function checkDatabaseStatus( db )
|
|||
if ( db.version === "" ) {
|
||||
createLatestDatabase( db );
|
||||
}
|
||||
// _updateSchema_v* will take care of calling the relevant update methods
|
||||
// to bring the database to the latest version
|
||||
else if ( db.version === "0.2" ) {
|
||||
_updateSchema_v3( db );
|
||||
}
|
||||
else if ( db.version === "0.3" ) {
|
||||
_updateSchema_v4( db )
|
||||
}
|
||||
}
|
||||
|
||||
function createLatestDatabase( db )
|
||||
|
@ -825,7 +836,8 @@ function createLatestDatabase( db )
|
|||
"password TEXT NOT NULL, " +
|
||||
"clientId TEXT NOT NULL, " +
|
||||
"clientSecret TEXT NOT NULL, " +
|
||||
"lastSync INTEGER DEFAULT 0" +
|
||||
"lastSync INTEGER DEFAULT 0," +
|
||||
"fetchUnread INTEGER DEFAULT 0" +
|
||||
")"
|
||||
);
|
||||
|
||||
|
@ -898,6 +910,19 @@ function _updateSchema_v3( db )
|
|||
tx.executeSql( "ALTER TABLE articles_next RENAME TO articles" );
|
||||
|
||||
db.changeVersion( db.version, "0.3" );
|
||||
_updateSchema_v4( db )
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function _updateSchema_v4( db )
|
||||
{
|
||||
db.transaction(
|
||||
function( tx ) {
|
||||
tx.executeSql( "ALTER TABLE servers ADD COLUMN fetchUnread INTEGER DEFAULT 0" );
|
||||
tx.executeSql( "UPDATE servers SET fetchUnread=0" );
|
||||
|
||||
db.changeVersion( db.version, "0.4" );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ Dialog {
|
|||
user: userField.text,
|
||||
password: passwordField.text,
|
||||
clientId: clientIdField.text,
|
||||
clientSecret: clientSecretField.text
|
||||
clientSecret: clientSecretField.text,
|
||||
fetchUnread: fetchUnreadSwitch.checked
|
||||
}
|
||||
|
||||
if ( serverId === -1 )
|
||||
|
@ -132,6 +133,13 @@ Dialog {
|
|||
text: serverSettings.clientSecret
|
||||
inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase | Qt.ImhSensitiveData
|
||||
}
|
||||
|
||||
TextSwitch {
|
||||
id: fetchUnreadSwitch
|
||||
width: parent.width
|
||||
checked: serverSettings.fetchUnread
|
||||
text: qsTr( "Fetch unread/archived articles" )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ Item {
|
|||
property string refreshToken
|
||||
property string tokenType
|
||||
property int tokenExpiry: 0
|
||||
property bool fetchUnread: false
|
||||
|
||||
signal articlesDownloaded( var list )
|
||||
signal connected
|
||||
|
@ -53,6 +54,7 @@ Item {
|
|||
refreshToken = null
|
||||
tokenType = null
|
||||
tokenExpiry = 0
|
||||
fetchUnread = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,6 +70,7 @@ Item {
|
|||
name = props.name
|
||||
url = props.url
|
||||
lastSync = props.lastSync
|
||||
fetchUnread = props.fetchUnread === 1
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +131,7 @@ Item {
|
|||
}
|
||||
else {
|
||||
console.debug( "Downloading articles changes since last sync" )
|
||||
var props = { url: url, since: lastSync, accessToken: accessToken }
|
||||
var props = { url: url, since: lastSync, accessToken: accessToken, archive: fetchUnread ? 1 : 0 }
|
||||
WallaBase.downloadArticles( props, onGetUpdatedArticlesDone )
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ QtObject {
|
|||
property string password
|
||||
property string clientId
|
||||
property string clientSecret
|
||||
property bool fetchUnread
|
||||
|
||||
signal error( string message )
|
||||
|
||||
|
@ -46,6 +47,7 @@ QtObject {
|
|||
password = null
|
||||
clientId = null
|
||||
clientSecret = null
|
||||
fetchUnread = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,6 +62,7 @@ QtObject {
|
|||
password = props.password
|
||||
clientId = props.clientId
|
||||
clientSecret = props.clientSecret
|
||||
fetchUnread = props.fetchUnread !== 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,10 @@
|
|||
<source>Client Secret</source>
|
||||
<translation>Secret du client</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Fetch unread/archived articles</source>
|
||||
<translation>Télécharger les articles lus / archivés</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ServersPage</name>
|
||||
|
|
|
@ -126,6 +126,10 @@
|
|||
<source>Client Secret</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Fetch unread/archived articles</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ServersPage</name>
|
||||
|
|
Loading…
Reference in New Issue