bugfixes reply in Friendica 3/2022 and image download
This commit is contained in:
parent
4ffae4ac31
commit
48a904b8c0
15 changed files with 909 additions and 855 deletions
|
@ -54,7 +54,8 @@ function dataRequest(login,photo,database,xhr,rootwindow) {
|
|||
// check if image exist and call download function
|
||||
|
||||
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photo.id, rootwindow, function (image){
|
||||
if(image==""){currentimageno=currentimageno+1}else{
|
||||
if(image=="" || typeof(image)=="undefined"){currentimageno=currentimageno+1}else{
|
||||
|
||||
try{
|
||||
var obj = JSON.parse(image);
|
||||
if (obj.hasOwnProperty('status')){
|
||||
|
@ -109,6 +110,30 @@ function dataRequest(login,photo,database,xhr,rootwindow) {
|
|||
}
|
||||
})
|
||||
}} catch (e){
|
||||
var helpfilename=photo.filename.substring(0,photo.filename.lastIndexOf("."));
|
||||
var filesuffix="";
|
||||
if (photo.type=="image/jpeg"){filesuffix=".jpg"}
|
||||
else if (photo.type=="image/png"){filesuffix=".png"}
|
||||
else {filesuffix=""}
|
||||
if (helpfilename==""){// check if file has any filename
|
||||
photo.filename=photo["id"]+filesuffix;
|
||||
}
|
||||
else{photo.filename=helpfilename+filesuffix}
|
||||
var link="";
|
||||
xhr.setUrl(Qt.resolvedUrl(photo.thumb));
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
xhr.setFilename(login.imagestore+'albums/'+photo.album+"/"+photo["filename"]);
|
||||
xhr.setDownloadtype("picture");
|
||||
xhr.download();
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from imageData where id = "'+photo["id"]+'"');
|
||||
if(result.rows.length === 1) {// use update
|
||||
result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+photo.id+'", created="'+photo.created+'", edited="'+photo.edited+'", profile="0", link="'+photo["thumb"]+'", filename="'+photo.filename+'",title="", desc="'+photo.desc+'", type="'+photo.type+'", width="0", height="0", album="'+photo.album+'", location="file://'+login.imagestore+'albums/'+photo.album+'/" where id="'+photo["id"]+'"');
|
||||
} else {// use insert print('... does not exists, create it')
|
||||
result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,photo.id,photo.created,photo.edited,'', photo.desc, photo.album, photo.filename, photo.type, '', '',0,photo["thumb"],'file://'+login.imagestore+'albums/'+photo.album+"/"]);
|
||||
}
|
||||
})
|
||||
print("Data retrieval failure! "+ e+obj);
|
||||
}
|
||||
}})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue