v0.6.1 Flatpak preparation and update on start for Linux

This commit is contained in:
LubuWest 2021-06-21 21:56:32 +02:00
parent 30bc7df431
commit ee851789ee
5 changed files with 63 additions and 49 deletions

View File

@ -401,22 +401,22 @@ function requestConversation(login,database,newsid,contacts,rootwindow,callback)
callback(news,newContacts) callback(news,newContacts)
})} })}
function conversationfromdb(database,user,conversationId,callback){ //function conversationfromdb(database,user,conversationId,callback){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]); // var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
db.transaction( function(tx) { // db.transaction( function(tx) {
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversationId+'" ORDER BY created_at ASC'); // var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversationId+'" ORDER BY created_at ASC');
var newsArray=[]; // var newsArray=[];
var allcontacts=getAllContacts(database,user); // var allcontacts=getAllContacts(database,user);
for(var i = 0; i < newsrs.rows.length; i++) { // for(var i = 0; i < newsrs.rows.length; i++) {
newsArray.push(newsrs.rows.item(i)); // newsArray.push(newsrs.rows.item(i));
newsArray[i].statusnet_html=Qt.atob(newsArray[i].statusnet_html); // newsArray[i].statusnet_html=Qt.atob(newsArray[i].statusnet_html);
newsArray[i].text=Qt.atob(newsArray[i].text); // newsArray[i].text=Qt.atob(newsArray[i].text);
newsArray[i].id=newsArray[i].status_id; // newsArray[i].id=newsArray[i].status_id;
newsArray[i]=fetchUsersForNews(database,user,newsArray[i],allcontacts); // newsArray[i]=fetchUsersForNews(database,user,newsArray[i],allcontacts);
if (helpernews.attachments!="" && newsArray[i].attachments!==null){newsArray[i].attachments=JSON.parse(Qt.atob(newsArray[i].attachments))}; // if (helpernews.attachments!="" && newsArray[i].attachments!==null){newsArray[i].attachments=JSON.parse(Qt.atob(newsArray[i].attachments))};
} // }
callback(newsArray)}) // callback(newsArray)})
} //}
function requestFavorites(login,database,contacts,rootwindow,callback){ function requestFavorites(login,database,contacts,rootwindow,callback){
Helperjs.friendicaRequest(login,"/api/favorites",rootwindow, function (obj){ Helperjs.friendicaRequest(login,"/api/favorites",rootwindow, function (obj){
@ -451,27 +451,18 @@ function chatsfromdb(database,login,messagetype,callback,stop_time){
var newsrs=tx.executeSql('select * from news WHERE username="'+login.username+'" AND statusnet_conversation_id="'+conversations[j] +'" AND messagetype="'+messagetype+'" ORDER BY created_at ASC'); var newsrs=tx.executeSql('select * from news WHERE username="'+login.username+'" AND statusnet_conversation_id="'+conversations[j] +'" AND messagetype="'+messagetype+'" ORDER BY created_at ASC');
//print(JSON.stringify(newsrs.rows.item(0))+JSON.stringify(newsrs.rows.item(1))) //print(JSON.stringify(newsrs.rows.item(0))+JSON.stringify(newsrs.rows.item(1)))
var helpernews=newsrs.rows.item(0); var helpernews=newsrs.rows.item(0);
helpernews.newscount=newsrs.rows.length; helpernews=cleanhelpernews(database,login.username,helpernews,allcontacts)
helpernews=fetchUsersForNews(database,login.username,helpernews,allcontacts);
helpernews.statusnet_html=Qt.atob(helpernews.statusnet_html);
helpernews.text=Qt.atob(helpernews.text);
helpernews.id=helpernews.status_id;
helpernews.friendica_author=objFromArray(allcontacts,"url",helpernews.friendica_owner);
if (helpernews.attachments!="" && helpernews.attachments!==null){helpernews.attachments=JSON.parse(Qt.atob(helpernews.attachments))};
helpernews.currentconversation=[]; helpernews.currentconversation=[];
for (var h = 0;h<newsrs.rows.length;h++){ for (var h = 0;h<newsrs.rows.length;h++){
var helpernews2=newsrs.rows.item(h); var helpernews2=newsrs.rows.item(h);
if(helpernews.id!=helpernews2.status_id){ if(helpernews.id!=helpernews2.status_id){
helpernews2.newscount=0; helpernews2.newscount=0;
helpernews2=fetchUsersForNews(database,login.username,helpernews2,allcontacts); helpernews2=cleanhelpernews(database,login.username,helpernews2,allcontacts)
helpernews2.statusnet_html=Qt.atob(helpernews2.statusnet_html);
helpernews2.text=Qt.atob(helpernews2.text);//print(h+" "+helpernews2.text)
helpernews2.id=helpernews2.status_id;
helpernews2.friendica_author=objFromArray(allcontacts,"url",helpernews2.friendica_owner);
if (helpernews2.attachments!="" && helpernews2.attachments!==null){helpernews2.attachments=JSON.parse(Qt.atob(helpernews2.attachments))};
helpernews.currentconversation.push(helpernews2) helpernews.currentconversation.push(helpernews2)
} }
} }
helpernews.newscount=newsrs.rows.length;
newsArray.push(helpernews); newsArray.push(helpernews);
} }
callback(newsArray,lastid); callback(newsArray,lastid);
@ -496,12 +487,17 @@ function allchatsfromdb(database,user,callback){
for(var j = 0; j< conversationIds.length; j++) { for(var j = 0; j< conversationIds.length; j++) {
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversationIds[j] +'" ORDER BY created_at ASC'); var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversationIds[j] +'" ORDER BY created_at ASC');
var helpernews=newsrs.rows.item(0); var helpernews=newsrs.rows.item(0);
//helpernews.newscount=newsrs.rows.length; var helpernews=cleanhelpernews(database,user,helpernews,allcontacts)
helpernews=fetchUsersForNews(database,user,helpernews,allcontacts); helpernews.currentconversation=[];
helpernews.statusnet_html=Qt.atob(helpernews.statusnet_html); for (var h = 0;h<newsrs.rows.length;h++){
helpernews.text=Qt.atob(helpernews.text); var helpernews2=newsrs.rows.item(h);
helpernews.id=helpernews.status_id;helpernews.friendica_author=objFromArray(allcontacts,"url",helpernews.friendica_owner); if(helpernews.id!=helpernews2.status_id){
if (helpernews.attachments!="" && helpernews.attachments!==null){helpernews.attachments=JSON.parse(Qt.atob(helpernews.attachments))}; helpernews2.newscount=0;
helpernews2=cleanhelpernews(database,user,helpernews2,allcontacts)
helpernews.currentconversation.push(helpernews2)
}
}
newsArray.push(helpernews); newsArray.push(helpernews);
countArray.push(newsrs.rows.length) countArray.push(newsrs.rows.length)
} }
@ -520,19 +516,34 @@ function oldchatfromdb(database,user,conversationId,lastpost,allcontacts,callbac
// var countArray=[]; // var countArray=[];
//var allcontacts=getAllContacts(database,user); //var allcontacts=getAllContacts(database,user);
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversationId +'" AND status_id<'+lastpost+' ORDER BY created_at ASC'); var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversationId +'" AND status_id<'+lastpost+' ORDER BY created_at ASC');
if(newsrs.rows.length>0){var helpernews=newsrs.rows.item(0); if(newsrs.rows.length>0){
var helpernews=newsrs.rows.item(0);
var helpernews=cleanhelpernews(database,user,helpernews,allcontacts)
helpernews.currentconversation=[];
for (var h = 0;h<newsrs.rows.length;h++){
var helpernews2=newsrs.rows.item(h);
if(helpernews.id!=helpernews2.status_id){
helpernews2.newscount=0;
helpernews2=cleanhelpernews(database,user,helpernews2,allcontacts)
helpernews.currentconversation.push(helpernews2)
}
}
var newscount=newsrs.rows.length; var newscount=newsrs.rows.length;
helpernews=fetchUsersForNews(database,user,helpernews,allcontacts);
helpernews.statusnet_html=Qt.atob(helpernews.statusnet_html);
helpernews.text=Qt.atob(helpernews.text);
helpernews.id=helpernews.status_id;helpernews.friendica_author=objFromArray(allcontacts,"url",helpernews.friendica_owner);
if (helpernews.attachments!="" && helpernews.attachments!==null){helpernews.attachments=JSON.parse(Qt.atob(helpernews.attachments))};
callback(helpernews,newscount);} callback(helpernews,newscount);}
// var conversationobject={news:helpernews,newscount:newscount}; // var conversationobject={news:helpernews,newscount:newscount};
// return conversationobject; // return conversationobject;
})} })}
function cleanhelpernews(database,user,helpernews,allcontacts){
helpernews=fetchUsersForNews(database,user,helpernews,allcontacts);
helpernews.statusnet_html=Qt.atob(helpernews.statusnet_html);
helpernews.text=Qt.atob(helpernews.text);
helpernews.id=helpernews.status_id;
helpernews.friendica_author=objFromArray(allcontacts,"url",helpernews.friendica_owner);
if (helpernews.attachments!="" && helpernews.attachments!==null){helpernews.attachments=JSON.parse(Qt.atob(helpernews.attachments))};
return helpernews
}
function getAllContacts(database,user){ function getAllContacts(database,user){

View File

@ -301,6 +301,7 @@ StackView{id:rootstackView
var IntentReceiverQml = component.createObject(root); var IntentReceiverQml = component.createObject(root);
} }
else if (osSettings.osType=="Linux"){ else if (osSettings.osType=="Linux"){
newstypeSignal("refresh")
var component = Qt.createComponent("qrc:/qml/genericqml/LinuxSync.qml"); var component = Qt.createComponent("qrc:/qml/genericqml/LinuxSync.qml");
var LinuxSyncQml = component.createObject(root); var LinuxSyncQml = component.createObject(root);
} }

View File

@ -175,8 +175,9 @@ Rectangle{
onDropped: { onDropped: {
if (messageSend.state==""){messageSend.state="active"} if (messageSend.state==""){messageSend.state="active"}
if (drop.keys.includes('text/uri-list')){ if (drop.keys.includes('text/uri-list')){
attachImageURLs.push(drop.text); var droptext = drop.text.replace(/(\r\n|\n|\r)/gm, "");
attachImage(drop.text)} attachImageURLs.push(droptext);
attachImage(droptext)}
else if (drop.keys.includes('text/html')){ else if (drop.keys.includes('text/html')){
bodyField.append(drop.html)} bodyField.append(drop.html)}
else if (drop.keys.includes('text/plain')){ else if (drop.keys.includes('text/plain')){

View File

@ -178,20 +178,20 @@ Rectangle{
default:messagetype=0; default:messagetype=0;
} }
//if(newstab.newstabstatus=="Timeline"){//print("lastnewsid "+lastnews_id); //if(newstab.newstabstatus=="Timeline"){//print("lastnewsid "+lastnews_id);
if(newstabstatus=="Timeline"){ if(newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline" ){
Newsjs.newsfromdb(root.db,root.login, messagetype,function(news){ Newsjs.newsfromdb(root.db,root.login, messagetype,function(news){
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'method':"", 'options':globaloptions}; var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'method':"", 'options':globaloptions};
newsWorker.sendMessage(msg); newsWorker.sendMessage(msg);
},false,lastnews_id)} },false,lastnews_id)}
//else if(newstab.newstabstatus=="Conversations"){ //else if(newstab.newstabstatus=="Conversations"){
else if(newstabstatus=="Conversations"){ else if(newstab.newstabstatus=="Conversations" || newstabstatus=="Conversations"){
Newsjs.chatsfromdb(root.db,root.login, messagetype,function(news){ Newsjs.chatsfromdb(root.db,root.login, messagetype,function(news){
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'method':"", 'options':globaloptions}; var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'method':"", 'options':globaloptions};
newsWorker.sendMessage(msg); newsWorker.sendMessage(msg);
},lastnews_id)} },lastnews_id)}
//else if (newstab.newstabstatus=="Notifications"){} //else if (newstab.newstabstatus=="Notifications"){}
else if (newstabstatus=="Notifications"){} else if (newstab.newstabstatus=="Notifications" || newstabstatus=="Notifications"){}
else{ else{print("no conversations or timeline "+newstabstatus);
switch(newsSwipeview.stacktype){ switch(newsSwipeview.stacktype){
case "Home":messagetype=0;break; case "Home":messagetype=0;break;
case "DirectMessages": messagetype=1;break; case "DirectMessages": messagetype=1;break;

View File

@ -205,7 +205,8 @@ Rectangle{
if (drop.keys.includes('text/uri-list')){ if (drop.keys.includes('text/uri-list')){
var urllist=drop.text.split('\n'); var urllist=drop.text.split('\n');
for(var i=0;i< urllist.length;i++){ for(var i=0;i< urllist.length;i++){
attachImage(urllist[i]) var droptext = urllist[i].replace(/(\r\n|\n|\r)/gm, "");
attachImage(droptext)
} }
} }
} }