This commit is contained in:
LubuWest 2019-12-10 21:12:32 +01:00
commit 7119d5bdf4
292 changed files with 790 additions and 16347 deletions

View file

@ -340,12 +340,15 @@ function cleanNews(database,callback){
//var maxnewsrs = tx.executeSql("SELECT DISTINCT maxnews FROM config");
var maxnewsrs = tx.executeSql("SELECT v FROM globaloptions WHERE k='max_news'");
var maxnews=1000; if(maxnewsrs.rows.length>0){ maxnews=maxnewsrs.rows.item(0).v};
var newscountrs = tx.executeSql('SELECT COUNT(*) from news');
var newscount = newscountrs.rows.item(0)["COUNT(*)"];//print("newscount "+newscount)
if (newscount>maxnews){
var lastvalidtimers= tx.executeSql('SELECT DISTINCT created_at FROM news ORDER BY created_at ASC LIMIT ' +(newscount-maxnews));
var lastvalidtime=lastvalidtimers.rows.item(newscount-maxnews-1).created_at;
var deleters = tx.executeSql('DELETE from news WHERE created_at<='+lastvalidtime)}
for (var i=0; i<6;i++){
if (i!=0){maxnews=maxnews/5}
var newscountrs = tx.executeSql('SELECT COUNT(*) from news WHERE messagetype='+i);
var newscount = newscountrs.rows.item(0)["COUNT(*)"];//print("newscount "+newscount)
if (newscount>maxnews){
var lastvalidtimers= tx.executeSql('SELECT DISTINCT created_at FROM news WHERE messagetype='+i+' ORDER BY created_at ASC LIMIT ' +(newscount-maxnews));
var lastvalidtime=lastvalidtimers.rows.item(newscount-maxnews-1).created_at;
var deleters = tx.executeSql('DELETE from news WHERE messagetype='+i+' AND created_at<='+lastvalidtime)}
}
callback()
})
}
@ -394,13 +397,40 @@ function processNews(api,data){
Helperjs.showMessage(qsTr("JSON status Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root)
}
else if (!(Array.isArray(newslist))){
//print("processNews not array"+newslist+JSON.stringify(newslist));
// print("processNews not array"+newslist+JSON.stringify(newslist));
// if(newslist.hasOwnProperty('id')){
// newslist.created_at=Date.parse(Newsjs.cleanDate(newslist.created_at));
// newslist.messagetype=5;
// newslist.friendica_author=cleanUser(newslist.friendica_author);
// newslist.user=cleanUser(newslist.user);
// if(newslist.in_reply_to_user_id){newslist.reply_user=Newsjs.objFromArray(allcontacts,"id",newslist.in_reply_to_user_id)}
// var dummynewslist=[newslist];
// Newsjs.storeNews(login,db,dummynewslist,root);
// switch(newsSwipeview.stacktype){
// case "Home":messagetype=0;break;
// case "DirectMessages": messagetype=1;break;
// case "Notifications":messagetype=2;break;
// case "Replies":messagetype=3;break;
// default:messagetype=0;
// }
// if((login.newsViewType=="Conversations")&&(newsSwipeview.stacktype=="Home")){
// Newsjs.chatsfromdb(db,login,messagetype,function(dbnews,lastid){
// lastnewsid=lastid;
// showNews(dbnews);
// })
// }
// else{Newsjs.newsfromdb(db,login,messagetype,function(dbnews,lastid){
// lastnewsid=lastid;
// showNews(dbnews)
// })}
// }
replytimer.restart()
}
else {
var allcontacts=[];
allcontacts=Newsjs.getAllContacts(db,login.username);
if (api=="/api/direct_messages/all"){
if (api=="/api/direct_messages/all" || api=="/api/direct_messages/conversation"){
for (var n in newslist){
newslist[n].created_at=Date.parse(Newsjs.cleanDate(newslist[n].created_at));
newslist[n].messagetype=1;
@ -412,6 +442,8 @@ function processNews(api,data){
newslist[n].friendica_owner=newslist[n].user;
newslist[n].friendica_author=newslist[n].user;
newslist[n].statusnet_html=newslist[n].text;
newslist[n].in_reply_to_user_id=newslist[n].recipient_id
if(newslist[n].in_reply_to_user_id){newslist[n].reply_user=Newsjs.objFromArray(allcontacts,"id",newslist[n].in_reply_to_user_id)}
}}
else if (api=="/api/friendica/notifications"){
for (var n in newslist){
@ -488,7 +520,7 @@ function processNews(api,data){
}
if (api=="/api/conversation/show"){
if (api=="/api/conversation/show"|| api=="/api/direct_messages/conversation"){
newslist.reverse();
newstab.conversation=newslist
}