From d09a55bcd921da39e51c3d2ff8b1eb0cd9e9d0c9 Mon Sep 17 00:00:00 2001 From: LubuWest Date: Wed, 11 Aug 2021 20:06:17 +0200 Subject: [PATCH] v0.6.2 Bugfix: download and upload public images, comments in timeline --- CHANGELOG.md | 3 +- README.md | 4 +- source-linux/common/alarmlinux.cpp | 4 +- source-linux/common/filesystem.cpp | 4 +- source-linux/common/uploadableimage.cpp | 8 +- source-linux/common/xhr.cpp | 1 + source-linux/js/helper.js | 5 +- source-linux/js/image.js | 257 ++++++++++-------- source-linux/js/newsworker.js | 2 +- source-linux/js/service.js | 2 +- source-linux/qml/newsqml/NewsImage.qml | 4 +- source-linux/qml/newsqml/NewsStack.qml | 8 +- .../qml/photoqml/ImageUploadDialog.qml | 6 +- source-linux/qml/photoqml/PhotoTab.qml | 37 ++- 14 files changed, 200 insertions(+), 145 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80edc7a..b74dda5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## v0.6.2 * Follow and Unfollow contacts (Friendica 2021.07 required) * Linux: App stays in systemtray after close, syncs in background - +* bugfix for bulk image upload and download of public images +* bugfix for conversations in timeline ## v0.6.1 * Add requestLegacyExternalStorage in AndroidManifest for attachment permissions diff --git a/README.md b/README.md index 38ef128..941defa 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,8 @@ ToDo: # Images # Currently supported: -* Download public and private own images to local directory -* Upload picture to album with descriptions(public), send from gallery +* Download public own images to local directory +* Upload public picture to album with descriptions, send from gallery * Delete own pictures and albums on client and server * Change name or album of existing picture * Show albums in grid, show images in album in grid and fullscreen diff --git a/source-linux/common/alarmlinux.cpp b/source-linux/common/alarmlinux.cpp index cdd75c3..5841543 100644 --- a/source-linux/common/alarmlinux.cpp +++ b/source-linux/common/alarmlinux.cpp @@ -45,14 +45,14 @@ ALARM::ALARM(QObject *parent) : QObject(parent){} void ALARM::setAlarm(int interval) { - qDebug() << interval; + //qDebug() << interval; QVariantMap message; message["value"] = interval; } void ALARM::notify(QString title, QString text, int id) { - qDebug() << title << text; + //qDebug() << title << text; // QVariantMap message; // message["title"] = title; // message["message"] = text; diff --git a/source-linux/common/filesystem.cpp b/source-linux/common/filesystem.cpp index d8a344d..2551260 100644 --- a/source-linux/common/filesystem.cpp +++ b/source-linux/common/filesystem.cpp @@ -83,7 +83,7 @@ void FILESYSTEM::makeDir(QString name) { QDir dir(m_Directory); if (dir.mkdir(name)){ - qDebug() << "makedir success" <0){ - for(var i=0;i< AllStoredImages.length;i++){ - var position=Helperjs.inArray(obj,"id",AllStoredImages[i]); - if (position>-1){obj.splice(position,1)} - } - } - callback(obj) - })} - else{callback(obj)} -})} - -function dataRequest(login,photoID,database,xhr,rootwindow) { - // check if image exist and call download function - Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photoID, rootwindow, function (image){ - try{ if(image==""){currentimageno=currentimageno+1}else{ - var obj = JSON.parse(image); - var helpfilename=obj.filename.substring(0,obj.filename.lastIndexOf(".")); - var filesuffix=""; - if (obj.type=="image/jpeg"){filesuffix=".jpg"} - else if (obj.type=="image/png"){filesuffix=".png"} - else {filesuffix=""} - if (helpfilename==""){// check if file has any filename - obj.filename=obj["id"]+filesuffix; + //print("return"+helperobject); + var obj=JSON.parse(helperobject); + if (onlynew){Helperjs.readField("id",database,"imageData",login.username,function(AllStoredImages){ + if (AllStoredImages.length>0){ + for(var i=0;i< AllStoredImages.length;i++){ + var position=Helperjs.inArray(obj,"id",AllStoredImages[i]); + if (position>-1){obj.splice(position,1)} + } } - else{obj.filename=helpfilename+filesuffix} - var link=""; - if(obj["link"][0]){link=obj["link"][0]} else{link=obj["link"]["4"]} - xhr.setUrl(Qt.resolvedUrl(link)); - xhr.setLogin(login.username+":"+Qt.atob(login.password)); - xhr.setFilename(login.imagestore+'albums/'+obj.album+"/"+obj["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 = "'+obj["id"]+'"'); - if(result.rows.length === 1) {// use update - result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+obj.id+'", created="'+obj.created+'", edited="'+obj.edited+'", profile="'+obj.profile+'", link="'+obj["link"]["4"]+'", filename="'+obj.filename+'",title="'+obj.title+'", desc="'+obj.desc+'", type="'+obj.type+'", width="'+obj.width+'", height="'+obj.height+'", album="'+obj.album+'", location="file://'+login.imagestore+'albums/'+obj.album+'/" where id="'+obj["id"]+'"'); - } else {// use insert print('... does not exists, create it') - result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,obj.id,obj.created,obj.edited, obj.title, obj.desc, obj.album, obj.filename, obj.type, obj.height, obj.width,obj. profile,obj["link"]["4"],'file://'+login.imagestore+'albums/'+obj.album+"/"]); - } - })}} - catch (e){print("Data retrieval failure! "+ e+obj);} -})} + callback(obj) + })} + else{callback(obj)} + })} + +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{ + try{ + var obj = JSON.parse(image); + if (obj.hasOwnProperty('status')){ + 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 = "'+obj["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+"/"]); + } + }) + }else{ + var helpfilename=obj.filename.substring(0,obj.filename.lastIndexOf(".")); + var filesuffix=""; + if (obj.type=="image/jpeg"){filesuffix=".jpg"} + else if (obj.type=="image/png"){filesuffix=".png"} + else {filesuffix=""} + if (helpfilename==""){// check if file has any filename + obj.filename=obj["id"]+filesuffix; + } + else{obj.filename=helpfilename+filesuffix} + var link=""; + if(obj["link"][0]){link=obj["link"][0]} else{link=obj["link"]["4"]} + xhr.setUrl(Qt.resolvedUrl(link)); + xhr.setLogin(login.username+":"+Qt.atob(login.password)); + xhr.setFilename(login.imagestore+'albums/'+obj.album+"/"+obj["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 = "'+obj["id"]+'"'); + if(result.rows.length === 1) {// use update + result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+obj.id+'", created="'+obj.created+'", edited="'+obj.edited+'", profile="'+obj.profile+'", link="'+link+'", filename="'+obj.filename+'",title="'+obj.title+'", desc="'+obj.desc+'", type="'+obj.type+'", width="'+obj.width+'", height="'+obj.height+'", album="'+obj.album+'", location="file://'+login.imagestore+'albums/'+obj.album+'/" where id="'+obj["id"]+'"'); + } else {// use insert print('... does not exists, create it') + result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,obj.id,obj.created,obj.edited, obj.title, obj.desc, obj.album, obj.filename, obj.type, obj.height, obj.width,obj. profile,link,'file://'+login.imagestore+'albums/'+obj.album+"/"]); + } + }) + }} catch (e){ + print("Data retrieval failure! "+ e+obj); + } + }}) +} function storeImagedata(login,database,imagedata,rootwindow) { // check if image exist and call download function - 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 = "'+imagedata["id"]+'"'); - if(result.rows.length === 1) {// use update - result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+imagedata.id+'", created="'+imagedata.created+'", edited="'+imagedata.edited+'", profile="'+imagedata.profile+'", link="'+imagedata.link[0]+'", filename="'+imagedata.filename+'",title="'+imagedata.title+'", desc="'+imagedata.desc+'", type="'+imagedata.type+'", width="'+imagedata.width+'", height="'+imagedata.height+'", album="'+imagedata.album+'", location="file://'+login.imagestore+'albums/'+imagedata.album+'/" where id="'+imagedata["id"]+'"'); - } else {// use insert print('... does not exists, create it') - result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,imagedata.id,imagedata.created,imagedata.edited, imagedata.title, imagedata.desc, imagedata.album, imagedata.filename, imagedata.type, imagedata.height, imagedata.width,imagedata. profile,imagedata.link[0],'file://'+login.imagestore+'albums/'+imagedata.album+"/"]); - } -})} + 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 = "'+imagedata["id"]+'"'); + if(result.rows.length === 1) {// use update + result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+imagedata.id+'", created="'+imagedata.created+'", edited="'+imagedata.edited+'", profile="'+imagedata.profile+'", link="'+imagedata.link[0]+'", filename="'+imagedata.filename+'",title="'+imagedata.title+'", desc="'+imagedata.desc+'", type="'+imagedata.type+'", width="'+imagedata.width+'", height="'+imagedata.height+'", album="'+imagedata.album+'", location="file://'+login.imagestore+'albums/'+imagedata.album+'/" where id="'+imagedata["id"]+'"'); + } else {// use insert print('... does not exists, create it') + result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,imagedata.id,imagedata.created,imagedata.edited, imagedata.title, imagedata.desc, imagedata.album, imagedata.filename, imagedata.type, imagedata.height, imagedata.width,imagedata. profile,imagedata.link[0],'file://'+login.imagestore+'albums/'+imagedata.album+"/"]); + } + })} function deleteImage(database,login,type,location,filesystem,rootwindow,callback) { // delete image locally and on server var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]); @@ -107,26 +138,26 @@ function deleteImage(database,login,type,location,filesystem,rootwindow,callback Helperjs.friendicaPostRequest(login,"/api/friendica/photo/delete?photo_id="+imageId,"","DELETE",rootwindow, function (obj){ //var deletereturn = JSON.parse(obj); print(obj); //if (deletereturn.result=="deleted"){ - db.transaction( function(tx) { - var deleters=tx.executeSql('DELETE FROM imageData WHERE location="'+rslocation+'" AND filename="'+rsfilename+'"'); }); - filesystem.Directory=rslocation.substring(7,rslocation.length-1); - filesystem.rmFile(rsfilename) - //} + db.transaction( function(tx) { + var deleters=tx.executeSql('DELETE FROM imageData WHERE location="'+rslocation+'" AND filename="'+rsfilename+'"'); }); + filesystem.Directory=rslocation.substring(7,rslocation.length-1); + filesystem.rmFile(rsfilename) + //} }) } else{ Helperjs.friendicaPostRequest(login,"/api/friendica/photoalbum/delete?album="+rsfilename,"","DELETE",rootwindow, function (obj){ //var deletereturn = JSON.parse(obj); //if (deletereturn.result=="deleted"){ - db.transaction( function(tx) { - var rs= tx.executeSql('SELECT DISTINCT location FROM imageData WHERE album="'+rsfilename+'" AND username="'+login.username+'"'); - var locationstring=rs.rows.item(0).location; - filesystem.Directory=locationstring.substring(7,locationstring.length-1); - filesystem.rmDir(); - var deleters=tx.executeSql('DELETE FROM imageData WHERE album="'+location+'"'); - }) - //} - }) + db.transaction( function(tx) { + var rs= tx.executeSql('SELECT DISTINCT location FROM imageData WHERE album="'+rsfilename+'" AND username="'+login.username+'"'); + var locationstring=rs.rows.item(0).location; + filesystem.Directory=locationstring.substring(7,locationstring.length-1); + filesystem.rmDir(); + var deleters=tx.executeSql('DELETE FROM imageData WHERE album="'+location+'"'); + }) + //} + }) } callback(location) }) @@ -136,13 +167,13 @@ function updateImage(database,login,type,filesystem,imageId,rootwindow,callback) var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]); Helperjs.readData(database,"imageData",login.username,function(obj){ db.transaction( function(tx) { - if (type=='image'){ - var deleters=tx.executeSql('DELETE FROM imageData WHERE location="'+obj[0].location+'" AND filename="'+obj[0].filename+'"'); - filesystem.Directory=obj[0].location - filesystem.rmFile(obj[0].filename) - } - }) - },"id",imageId); + if (type=='image'){ + var deleters=tx.executeSql('DELETE FROM imageData WHERE location="'+obj[0].location+'" AND filename="'+obj[0].filename+'"'); + filesystem.Directory=obj[0].location + filesystem.rmFile(obj[0].filename) + } + }) + },"id",imageId); callback() } @@ -153,7 +184,7 @@ function deleteContacts(database,user,callback) { // does nothing useful at the db.transaction( function(tx) { result1= tx.executeSql('SELECT * FROM contacts a LEFT OUTER JOIN news b ON a.url==b.uid'); result2= tx.executeSql('SELECT * FROM contacts a LEFT OUTER JOIN news b ON a.url==b.uid'); - callback(result)}) + callback(result)}) } //function requestFriendsAlbumPictures(login,friend,rootwindow,callback){ @@ -173,10 +204,10 @@ function deleteContacts(database,user,callback) { // does nothing useful at the //} function newRequestFriendsAlbumPictures(login,friend,rootwindow,callback){//print("newRequestFriendsAlbumPictures"); -// screenscraping of albums page of contact with remoteAuth + // screenscraping of albums page of contact with remoteAuth //commented out for broken remoteauth Helperjs.friendicaRemoteAuthRequest(login,friend.url.replace("profile","photos"),friend.url,rootwindow,function(photohtml){ - //Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){ + //Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){ try {var obj=JSON.parse(photohtml);//print ("Photohtml: "+photohtml) if (obj.hasOwnProperty('status')){ Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){ @@ -197,14 +228,14 @@ function getAlbumFromHtml(photohtml,remoteAuthBool,rootwindow,callback){ var albumlink = arr[i].substring(arr[i].indexOf('http'),arr[i].indexOf('class')-2); var albumname=arr[i].substring(arr[i].indexOf('/span')+6,arr[i].indexOf('')-1); var album={'link':albumlink,'name':albumname}//print(albumlink+" "+albumname); - photoarray.push(album); + photoarray.push(album); } callback(photoarray,remoteAuthBool) } function newRequestFriendsPictures(login,link,friend,remoteAuthBool,remoteauth,rootwindow,callback){ -// screenscraping of pictures page for given album + // screenscraping of pictures page for given album if (remoteAuthBool){ remoteauth.setUrl(login.server); remoteauth.setLogin(login.username+":"+Qt.atob(login.password)); @@ -225,20 +256,20 @@ function newRequestFriendsPictures(login,link,friend,remoteAuthBool,remoteauth,r function getPictureFromHtml(photohtml,remoteAuthBool,callback){ var photoarray=[]; - var basehtml=photohtml.substring(photohtml.indexOf('',photohtml.indexOf('',photohtml.indexOf('-1){ //theme 1 - var arr = photohtml.split("photo-album-image-wrapper-end");} + // old theme + if (photohtml.indexOf("photo-album-image-wrapper-end")>-1){ //theme 1 + var arr = photohtml.split("photo-album-image-wrapper-end");} -// other themes - if (photohtml.indexOf("photo-album-wrapper")>-1){ //theme 2 + // other themes + if (photohtml.indexOf("photo-album-wrapper")>-1){ //theme 2 var photoarea=photohtml.substring(photohtml.indexOf("photo-album-wrapper"),photohtml.indexOf("photo-album-end")) - var arr = photoarea.split("");} - //print("Url: "+login.server+ "Contacturl: "+friend.url) -// remoteauth.setUrl(login.server); -// remoteauth.setLogin(login.username+":"+Qt.atob(login.password)); -// remoteauth.setContacturl(friend.url); + var arr = photoarea.split("");} + //print("Url: "+login.server+ "Contacturl: "+friend.url) + // remoteauth.setUrl(login.server); + // remoteauth.setLogin(login.username+":"+Qt.atob(login.password)); + // remoteauth.setContacturl(friend.url); for (var i=0;i-1){ //theme 1 - var arr = photohtml.split("photo-album-image-wrapper-end");} + // old theme + if (photohtml.indexOf("photo-album-image-wrapper-end")>-1){ //theme 1 + var arr = photohtml.split("photo-album-image-wrapper-end");} -// other themes - if (photohtml.indexOf("photo-album-wrapper")>-1){ //theme 2 - var photoarea=photohtml.substring(photohtml.indexOf("photo-album-wrapper"),photohtml.indexOf("photo-album-end")) - var arr = photoarea.split("");} + // other themes + if (photohtml.indexOf("photo-album-wrapper")>-1){ //theme 2 + var photoarea=photohtml.substring(photohtml.indexOf("photo-album-wrapper"),photohtml.indexOf("photo-album-end")) + var arr = photoarea.split("");} - for (var i=0;i1)){ + if (newsitemobject.hasOwnProperty("currentconversation")&&(newsitemobject.currentconversation.length>0)){ newsitemobject.lastcomment=beautify(newsitemobject.currentconversation[newsitemobject.currentconversation.length-1],msg); newsitemobject.lastcomment.indent=1 //print("Currentconversation" + newsitemobject.currentconversation.length+JSON.stringify(newsitemobject.lastcomment)) diff --git a/source-linux/js/service.js b/source-linux/js/service.js index 84feb2a..0543199 100644 --- a/source-linux/js/service.js +++ b/source-linux/js/service.js @@ -291,7 +291,7 @@ function readConfig(database,callback,filter,filtervalue) { // reads config } var rsObject={server:rsArray[0].server,username:rsArray[0].username, password:rsArray[0].password,imagestore:rsArray[0].imagestore,isActive:rsArray[0].isActive, newsViewType:rsArray[0].newsViewType,permissions:JSON.parse(rsArray[0].permissions),maxContactAge:rsArray[0].maxContactAge,APIVersion:rsArray[0].APIVersion,addons:rsArray[0].addons}; if (rsObject.newsViewType!="" && rsObject.newsViewType!=null){updateNewsviewtype(database,rsObject.newsViewType)} - } else {print("config empty");var rsObject=""} + } else {var rsObject=""} callback(rsObject)}} ) } diff --git a/source-linux/qml/newsqml/NewsImage.qml b/source-linux/qml/newsqml/NewsImage.qml index 9527959..42ed018 100644 --- a/source-linux/qml/newsqml/NewsImage.qml +++ b/source-linux/qml/newsqml/NewsImage.qml @@ -29,9 +29,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -import QtQuick 2.9 +import QtQuick 2.15 AnimatedImage {id:gif; width:toprow.width; + cache:false + smooth: false //property string mimetype:"" fillMode: Image.PreserveAspectFit; onStatusChanged: {playing = (status == AnimatedImage.Ready)} diff --git a/source-linux/qml/newsqml/NewsStack.qml b/source-linux/qml/newsqml/NewsStack.qml index e77cd69..3b20705 100644 --- a/source-linux/qml/newsqml/NewsStack.qml +++ b/source-linux/qml/newsqml/NewsStack.qml @@ -173,7 +173,13 @@ Rectangle{ function getOldNews(){ var currentTime= new Date(); - try{var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;} catch(e){var lastnews_id=99999999999999 } + var oldnewsitemobject=newsModel.get(newsModel.count-1).newsitemobject; + try{ if(oldnewsitemobject.hasOwnProperty("lastcomment")){ + var lastnews_id=oldnewsitemobject.lastcomment.created_at; + }else{ + var lastnews_id=oldnewsitemobject.created_at; + } + } catch(e){print(e);var lastnews_id=99999999999999 } var messagetype=0; switch(newsSwipeview.stacktype){ case "Home":messagetype=0;break; diff --git a/source-linux/qml/photoqml/ImageUploadDialog.qml b/source-linux/qml/photoqml/ImageUploadDialog.qml index 5ab0c48..8a80818 100644 --- a/source-linux/qml/photoqml/ImageUploadDialog.qml +++ b/source-linux/qml/photoqml/ImageUploadDialog.qml @@ -53,7 +53,7 @@ Rectangle{ xhr.setLogin(login.username+":"+Qt.atob(login.password)); xhr.clearParams(); xhr.setParam("desc",imageUploadModel.get(inumber).description); - xhr.setParam("album", album.currentText); + if(album.editText!=""){xhr.setParam("album", album.editText)}else{xhr.setParam("album", album.currentText)}; //if (group_allow.length>0) {xhr.setParam("group_allow", Helperjs.cleanArray(group_allow))}; //if (group_deny.length>0) {xhr.setParam("group_deny", Helperjs.cleanArray(group_deny))}; //if (contact_allow.length>0) {xhr.setParam("contact_allow", Helperjs.cleanArray(contact_allow))}; @@ -96,7 +96,7 @@ Rectangle{ }else{ Imagejs.requestList(login,db, true,root,function(obj){ fotorectangle.newimages=obj; - imageDialog.destroy() + photoStack.pop() }) }} else{ @@ -304,7 +304,7 @@ Rectangle{ text: imageId==""?qsTr("Upload"):qsTr("Change") font.pointSize: osSettings.bigFontSize onClicked:{ - if(album.currentText==""){Helperjs.showMessage(qsTr("Error"),qsTr(" No album name given"), imageDialog)} + if(album.currentText==""&&album.editText==""){Helperjs.showMessage(qsTr("Error"),qsTr(" No album name given"), imageDialog)} else if (imageId!=""){uploadBusy.running=true; updateImage()} else{newimageProgress.visible=true; if (imageUploadModel.count>0){ diff --git a/source-linux/qml/photoqml/PhotoTab.qml b/source-linux/qml/photoqml/PhotoTab.qml index e71751c..9d5a025 100644 --- a/source-linux/qml/photoqml/PhotoTab.qml +++ b/source-linux/qml/photoqml/PhotoTab.qml @@ -61,22 +61,28 @@ StackView{ if(albums.indexOf(fotorectangle.newimages[i].album)==-1){ filesystem.Directory=root.login.imagestore+"/albums"; filesystem.makeDir(fotorectangle.newimages[i].album)} - ownimagelist.push(root.login.server+"/api/friendica/photo?scale='0'&photo_id="+fotorectangle.newimages[i].id); + + //ownimagelist.push(root.login.server+"/api/friendica/photo?scale='0'&photo_id="+fotorectangle.newimages[i].id); } + Imagejs.dataRequest(login,fotorectangle.newimages[0],db,xhr,fotorectangle); }) - xhr.setLogin(login.username+":"+Qt.atob(login.password)); - xhr.setImagedir(login.imagestore); - xhr.setFilelist(ownimagelist); - xhr.setDownloadtype("picturelist"); - xhr.getlist(); +// xhr.setLogin(login.username+":"+Qt.atob(login.password)); +// xhr.setImagedir(login.imagestore); +// xhr.setFilelist(ownimagelist); +// xhr.setDownloadtype("picturelist"); +// xhr.getlist(); newImagesProgress.visible=true } } onCurrentimagenoChanged:{ - if(fotorectangle.currentimageno==fotorectangle.newimages.length){newImagesProgress.visible=false;showFotos(root.login,""); - fotorectangle.newimages=[];fotorectangle.currentimageno=0} - // download next image + if(fotorectangle.currentimageno==fotorectangle.newimages.length){ + newImagesProgress.visible=false;showFotos(root.login,""); + fotorectangle.newimages=[];fotorectangle.currentimageno=0 + }else{ + // download next image + Imagejs.dataRequest(login,fotorectangle.newimages[currentimageno],db,xhr,fotorectangle) + } } Connections{ @@ -90,10 +96,17 @@ StackView{ function onDownloaded(type,url,filename,i){ if(type=="picture"){fotorectangle.currentimageno=fotorectangle.currentimageno+1} } - function onError(data,url,api,code){if(data=="picturelist"){ + function onError(data,url,api,code){//print("Url "+url+" api " +api + " data "+data) + if(data=="picturelist"){ var requestid=url.substring(url.lastIndexOf("=")+1); - Imagejs.dataRequest(login,requestid,db,xhr,fotorectangle) - } else {fotorectangle.currentimageno=fotorectangle.currentimageno+1} + Imagejs.dataRequest(login,requestid,db,xhr,fotorectangle); + fotorectangle.currentimageno=fotorectangle.currentimageno+1 + } else if (data=="picture"){ + Helperjs.deleteData(root.db,"imageData",root.login.username,function(){ + fotorectangle.currentimageno=fotorectangle.currentimageno+1 + },"link",url) + }else{ + fotorectangle.currentimageno=fotorectangle.currentimageno+1} } } // Connections{