v0.5.2
This commit is contained in:
parent
3e8585aa93
commit
c1bdcbf963
48 changed files with 1333 additions and 1229 deletions
|
@ -288,7 +288,7 @@ function readConfig(database,callback,filter,filtervalue) { // reads config
|
|||
}
|
||||
|
||||
function readActiveConfig(database){
|
||||
var obj;
|
||||
var obj="";
|
||||
readConfig(database,function(config){obj=config},"isActive", 0);
|
||||
return obj;
|
||||
}
|
||||
|
@ -341,12 +341,15 @@ function cleanNews(database,callback){
|
|||
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};
|
||||
for (var i=0; i<6;i++){
|
||||
if (i!=0){maxnews=maxnews/5}
|
||||
if (i!=0){var maxnewsa=maxnews/5}else{maxnewsa=maxnews}
|
||||
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 newscount = 0;
|
||||
if (newscountrs.rows.length>0){newscount=newscountrs.rows.item(0)["COUNT(*)"]};//print(i+"newscount "+newscount)
|
||||
if (newscount>maxnewsa){
|
||||
var lastvalidtimers= tx.executeSql('SELECT DISTINCT created_at FROM news WHERE messagetype='+i+' ORDER BY created_at ASC LIMIT ' +(newscount-maxnewsa));
|
||||
// print('SELECT DISTINCT created_at FROM news WHERE messagetype='+i+' ORDER BY created_at ASC LIMIT ' +(newscount-maxnewsa))
|
||||
// print(JSON.stringify(lastvalidtimers.rows.item(newscount-maxnewsa-1)))
|
||||
var lastvalidtime=lastvalidtimers.rows.item(newscount-maxnewsa-1).created_at;
|
||||
var deleters = tx.executeSql('DELETE from news WHERE messagetype='+i+' AND created_at<='+lastvalidtime)}
|
||||
}
|
||||
callback()
|
||||
|
@ -387,7 +390,8 @@ function updateContactInDB(login,database,isFriend,contact){// for newstab and f
|
|||
}
|
||||
|
||||
function processNews(api,data){
|
||||
//print(api + data);
|
||||
//print("processNews "+api + data);
|
||||
|
||||
try{var newslist=JSON.parse(data)} catch(e){newsBusy.running=false;};
|
||||
if (data==""){}
|
||||
else if (typeof(newslist)=='undefined'){
|
||||
|
@ -397,34 +401,6 @@ 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));
|
||||
// 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 {
|
||||
|
@ -624,6 +600,10 @@ function updateView(viewtype){
|
|||
if (viewtype==="Conversations"){Newsjs.allchatsfromdb(db,login.username,function(temp){
|
||||
newsStack.allchats=temp
|
||||
})}
|
||||
if ((osSettings.osType=="Android") && root.globaloptions.hasOwnProperty("syncinterval") && root.globaloptions.syncinterval !=null && root.globaloptions.syncinterval !=0){
|
||||
//alarm.setAlarm(root.globaloptions.syncinterval);
|
||||
setBackgroundsync()
|
||||
}
|
||||
}
|
||||
|
||||
function showGroups(){
|
||||
|
@ -638,6 +618,17 @@ function showGroups(){
|
|||
})
|
||||
}
|
||||
|
||||
function setBackgroundsync(){
|
||||
Helperjs.readData(db,"globaloptions","",function(lastsync){
|
||||
//print("Lastsync "+(parseFloat(lastsync[0]["v"])+120) + " Date "+Date.now()/1000 + " "+((parseFloat(lastsync[0]["v"])+120)<(Date.now()/1000)))
|
||||
if((lastsync.length>0)&&((parseFloat(lastsync[0]["v"])+120)<(Date.now()/1000))){
|
||||
alarm.setAlarm(root.globaloptions.syncinterval);
|
||||
|
||||
}
|
||||
|
||||
},"k","lastsync")
|
||||
}
|
||||
|
||||
function getGroupnews(list){
|
||||
newstab.newstabstatus="Group news";
|
||||
newsBusy.running=true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue