v0.6.1 no conversation update with news length 0

This commit is contained in:
LubuWest 2021-06-22 21:47:06 +02:00
parent 72d0f8ff69
commit c5df85b820
2 changed files with 31 additions and 22 deletions

View file

@ -138,7 +138,7 @@ if(msg.deleteId!==undefined)
msg.model.sync() msg.model.sync()
} }
else{ else{
if(msg.method=="refresh" ||msg.method=="conversation"){msg.model.clear()}; if(msg.method=="refresh" ||(msg.method=="conversation"&&msg.news.length>0)){msg.model.clear()};
msg.model.sync() msg.model.sync()
for (var j=0;j<msg.news.length;j++){ for (var j=0;j<msg.news.length;j++){
if (msg.news[j]) { if (msg.news[j]) {

View file

@ -61,7 +61,7 @@ Rectangle{
newsBusy.running=true; newsBusy.running=true;
replySignal(""); replySignal("");
//messagesend.state=""; //messagesend.state="";
newsModel.clear(); //newsModel.clear();
switch(newstype){ switch(newstype){
case "timeline": case "timeline":
newstab.newstabstatus="Timeline"; newstab.newstabstatus="Timeline";
@ -71,6 +71,7 @@ Rectangle{
})}catch(e){Helperjs.showMessage("Error",e,root)}; })}catch(e){Helperjs.showMessage("Error",e,root)};
break; break;
case "conversation": case "conversation":
newsStack.updateMethodNews="conversation";
newstab.newstabstatus="Conversations"; newstab.newstabstatus="Conversations";
Newsjs.chatsfromdb(root.db,root.login,0,function(news,lastid){ Newsjs.chatsfromdb(root.db,root.login,0,function(news,lastid){
lastnewsid=lastid; lastnewsid=lastid;
@ -105,10 +106,12 @@ Rectangle{
var searchItem = component.createObject(newsStack,{y:mm,x:leftoffset,width:root.width-leftoffset,height: 5*mm}); var searchItem = component.createObject(newsStack,{y:mm,x:leftoffset,width:root.width-leftoffset,height: 5*mm});
break; break;
case "refresh": case "refresh":
if (newstab.newstabstatus=="Timeline"){ if (newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline"){
newsStack.updateMethodNews="append" newsStack.updateMethodNews="append"
} else {newsStack.updateMethodNews="refresh"} } else if (newstab.newstabstatus=="Conversations" || newstabstatus=="Conversations"){
//print("Refresh "+newsSwipeview.stacktype+newstab.newstabstatus) newsStack.updateMethodNews="conversation"}
else {newsStack.updateMethodNews="refresh"}
if (newsSwipeview.stacktype=="Home"){ if (newsSwipeview.stacktype=="Home"){
Service.updateView(newstab.newstabstatus) Service.updateView(newstab.newstabstatus)
} }
@ -120,9 +123,11 @@ Rectangle{
} }
break; break;
default: default:
if (newstab.newstabstatus=="Timeline"){ if (newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline"){
newsStack.updateMethodNews="append" newsStack.updateMethodNews="append"
} else {newsStack.updateMethodNews="refresh"} } else if (newstab.newstabstatus=="Conversations" || newstabstatus=="Conversations"){
newsStack.updateMethodNews="conversation"}
else {newsStack.updateMethodNews="refresh"}
//root.contactLoadType="news"; //root.contactLoadType="news";
if (newsSwipeview.stacktype=="Home"){ if (newsSwipeview.stacktype=="Home"){
Service.updateView(newstab.newstabstatus) Service.updateView(newstab.newstabstatus)
@ -151,7 +156,7 @@ Rectangle{
function search(term){//print("Search "+term) function search(term){
if (term!=""){ if (term!=""){
//newstab.newstabstatus="Search"; //newstab.newstabstatus="Search";
newstabstatus="Search"; newstabstatus="Search";
@ -166,7 +171,7 @@ Rectangle{
newsView.anchors.topMargin=mm newsView.anchors.topMargin=mm
} }
function getOldNews(){print("newstab.newstabstatus" +newstab.newstabstatus) function getOldNews(){
var currentTime= new Date(); var currentTime= new Date();
try{var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;} catch(e){var lastnews_id=99999999999999 } try{var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;} catch(e){var lastnews_id=99999999999999 }
var messagetype=0; var messagetype=0;
@ -177,21 +182,21 @@ Rectangle{
case "Replies":messagetype=3;break; case "Replies":messagetype=3;break;
default:messagetype=0; default:messagetype=0;
} }
//if(newstab.newstabstatus=="Timeline"){//print("lastnewsid "+lastnews_id);
if(newstab.newstabstatus=="Timeline" || 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" || 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" || newstabstatus=="Notifications"){} else if (newstab.newstabstatus=="Notifications" || newstabstatus=="Notifications"){}
else{print("no conversations or timeline "+newstabstatus); else{
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;
@ -199,7 +204,7 @@ Rectangle{
case "Replies":messagetype=3;break; case "Replies":messagetype=3;break;
default:messagetype=0; default:messagetype=0;
} }
//newsStack.appendNews=true;
try{xhr.setParam("max_id",newsModel.get(newsModel.count-1).newsitemobject.id-1);}catch(e){} try{xhr.setParam("max_id",newsModel.get(newsModel.count-1).newsitemobject.id-1);}catch(e){}
xhr.get() xhr.get()
} }
@ -218,14 +223,16 @@ Rectangle{
} }
Timer {id:replytimer; interval: 1000; running: false; repeat: false Timer {id:replytimer; interval: 1000; running: false; repeat: false
onTriggered: {"replytimer triggered"; onTriggered: {
newsBusy.running=true; newsBusy.running=true;
if(newstab.newstabstatus=="Conversation"){ if(newstab.newstabstatus=="Conversation"){
showConversation(newsStack.timelineIndex-1,newsModel.get(0).newsitemobject)} showConversation(newsStack.timelineIndex-1,newsModel.get(0).newsitemobject)}
else{ else{
if (newstab.newstabstatus=="Timeline"){ if (newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline"){
newsStack.updateMethodNews="append" newsStack.updateMethodNews="append"
} else {newsStack.updateMethodNews="refresh"} } else if (newstab.newstabstatus=="Conversations" || newstabstatus=="Conversations"){
newsStack.updateMethodNews="conversation"}
else {newsStack.updateMethodNews="refresh"}
if (newsSwipeview.stacktype=="Home"){ if (newsSwipeview.stacktype=="Home"){
Service.updateView(newstab.newstabstatus) Service.updateView(newstab.newstabstatus)
} }
@ -269,7 +276,7 @@ Rectangle{
Service.updateView("Replies") Service.updateView("Replies")
} }
} }
else {print("Footer newstab.newstabstatus "+newstab.newstabstatus);getOldNews();} else {getOldNews();}
} }
} }
} }
@ -321,10 +328,12 @@ Rectangle{
var onlynew=true; var onlynew=true;
newsBusy.running=true; newsBusy.running=true;
viewdragged=false viewdragged=false
if (newstab.newstabstatus=="Timeline"){ if (newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline"){
newsStack.updateMethodNews="append" newsStack.updateMethodNews="append"
} else {newsStack.updateMethodNews="refresh"} } else if (newstab.newstabstatus=="Conversations" || newstabstatus=="Conversations"){
//root.contactLoadType="news"; newsStack.updateMethodNews="conversation"}
else {newsStack.updateMethodNews="refresh"}
if (newsSwipeview.stacktype=="Home"){ if (newsSwipeview.stacktype=="Home"){
Newsjs.getLastNews(root.login,root.db,function(currentlastnews){ Newsjs.getLastNews(root.login,root.db,function(currentlastnews){
if (currentlastnews>lastnewsid){ if (currentlastnews>lastnewsid){
@ -357,7 +366,7 @@ Rectangle{
} }
} }
onViewdraggedpositiveChanged: { onViewdraggedpositiveChanged: {
if (viewdraggedpositive){print("listview dragged newstab.newstabstatus "+newstab.newstabstatus) if (viewdraggedpositive){
getOldNews(); getOldNews();
viewdraggedpositive=false viewdraggedpositive=false
} }