groups download
This commit is contained in:
parent
3703c116aa
commit
a2cea6464c
|
@ -83,17 +83,28 @@ function requestFriends(login,database,rootwindow,callback){
|
||||||
function requestGroups(login,database,rootwindow,callback){
|
function requestGroups(login,database,rootwindow,callback){
|
||||||
// retrieve, save and return groups. Other features currently not implemented
|
// retrieve, save and return groups. Other features currently not implemented
|
||||||
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]);
|
||||||
Helperjs.friendicaRequest(login,"/api/friendica/group_show",rootwindow, function (obj){
|
//Helperjs.friendicaRequest(login,"/api/friendica/circle_show",rootwindow, function (obj){print("obj"+obj)
|
||||||
var groups=JSON.parse(obj);
|
|
||||||
db.transaction( function(tx) {
|
db.transaction( function(tx) {
|
||||||
var result = tx.executeSql('DELETE from groups where username="'+login.username+'"'); // clean old groups
|
var result = tx.executeSql('DELETE from groups where username="'+login.username+'"'); // clean old groups
|
||||||
for (var i=0;i<groups.length;i++){
|
|
||||||
var memberarray=[]; for (var user in groups[i].user){memberarray.push(parseInt(groups[i].user[user].id))}
|
|
||||||
//print("Members: "+groups[i].user)
|
|
||||||
var result2 = tx.executeSql('INSERT INTO groups VALUES (?,?,?,?)', [login.username,groups[i].name,groups[i].gid,JSON.stringify(memberarray)])}
|
|
||||||
callback()
|
|
||||||
});
|
});
|
||||||
})}
|
let groups=[];
|
||||||
|
Helperjs.friendicaRequest(login,"/api/v1/lists",rootwindow,function(listsobj){
|
||||||
|
var lists=JSON.parse(listsobj)
|
||||||
|
for (var list in lists){
|
||||||
|
if (Number.isInteger(parseInt(lists[list].id))){
|
||||||
|
Helperjs.friendicaRequest(login,"/api/v1/lists/"+lists[list].id+"/accounts?limit=0", rootwindow,function (obj){
|
||||||
|
let members=JSON.parse(obj);
|
||||||
|
let memberarray=members.map((x)=>parseInt(x.id));
|
||||||
|
db.transaction( function(tx) {
|
||||||
|
var result2 = tx.executeSql('INSERT INTO groups VALUES (?,?,?,?)', [login.username,lists[list].title,lists[list].id,JSON.stringify(memberarray)])
|
||||||
|
groups.push({groupname:lists[list].title,gid:lists[list].id,members:memberarray})
|
||||||
|
});
|
||||||
|
callback(groups)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function listFriends(login,database,callback,filter,isFriend=0){
|
function listFriends(login,database,callback,filter,isFriend=0){
|
||||||
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]);
|
||||||
|
|
|
@ -80,7 +80,7 @@ Rectangle {
|
||||||
height: 1.7*root.fontFactor*osSettings.bigFontSize
|
height: 1.7*root.fontFactor*osSettings.bigFontSize
|
||||||
}
|
}
|
||||||
TabButton {
|
TabButton {
|
||||||
text: qsTr("Groups")
|
text: qsTr("Circles")
|
||||||
font.pointSize: osSettings.systemFontSize
|
font.pointSize: osSettings.systemFontSize
|
||||||
height: 1.7*root.fontFactor*osSettings.bigFontSize
|
height: 1.7*root.fontFactor*osSettings.bigFontSize
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,12 @@ Item{
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin:menuButton.width
|
anchors.rightMargin:menuButton.width
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Newsjs.requestGroups(root.login,root.db,root,function(){
|
Newsjs.requestGroups(root.login,root.db,root,function(groups){
|
||||||
groupsGridTab.showGroups(root.login.username)})}
|
for (let n in groups){
|
||||||
|
groupsModel.append({"group":groups[n]});
|
||||||
|
}
|
||||||
|
//groupsGridTab.showGroups(root.login.username)})
|
||||||
|
})}
|
||||||
}
|
}
|
||||||
// MButton {
|
// MButton {
|
||||||
// id: newGroupButton
|
// id: newGroupButton
|
||||||
|
|
|
@ -95,7 +95,7 @@ Item {
|
||||||
width:parent.width
|
width:parent.width
|
||||||
font.pointSize: osSettings.systemFontSize
|
font.pointSize: osSettings.systemFontSize
|
||||||
font.bold: account.username==login.username && friendsTabView.currentIndex==2
|
font.bold: account.username==login.username && friendsTabView.currentIndex==2
|
||||||
text: " "+qsTr("Groups")
|
text: " "+qsTr("Circles")
|
||||||
MouseArea{
|
MouseArea{
|
||||||
anchors.fill:parent
|
anchors.fill:parent
|
||||||
onClicked:{
|
onClicked:{
|
||||||
|
|
|
@ -355,7 +355,7 @@ Page {
|
||||||
contactBusy.running=false;
|
contactBusy.running=false;
|
||||||
}
|
}
|
||||||
function onSuccess(data,api){
|
function onSuccess(data,api){
|
||||||
if (api=="/api/statuses/user_timeline"){
|
if (api=="/api/statuses/user_timeline" || api=="/api/conversation/show"|| api=="/api/direct_messages/conversation"){
|
||||||
if (data!=""){
|
if (data!=""){
|
||||||
Service.processNews(api,data)
|
Service.processNews(api,data)
|
||||||
}else{contactBusy.running=false}
|
}else{contactBusy.running=false}
|
||||||
|
|
|
@ -118,7 +118,7 @@ Page {
|
||||||
|
|
||||||
Connections{
|
Connections{
|
||||||
target: root
|
target: root
|
||||||
function onConversationChanged(){
|
function onConversationChanged(){print(conversation+" conversation "+JSON.stringify(root.conversation))
|
||||||
// if(root.conversation.length==0){
|
// if(root.conversation.length==0){
|
||||||
// rootstackView.pop()
|
// rootstackView.pop()
|
||||||
// } else {
|
// } else {
|
||||||
|
|
|
@ -53,6 +53,7 @@ Page{
|
||||||
}
|
}
|
||||||
|
|
||||||
function showConversation(conversationIndex,newsitemobject){
|
function showConversation(conversationIndex,newsitemobject){
|
||||||
|
expectScreenUpdate=true;
|
||||||
if(newsitemobject.messagetype==0 || newsitemobject.messagetype==3){
|
if(newsitemobject.messagetype==0 || newsitemobject.messagetype==3){
|
||||||
xhr.setAccount(login);
|
xhr.setAccount(login);
|
||||||
xhr.setApi("/api/conversation/show");
|
xhr.setApi("/api/conversation/show");
|
||||||
|
|
|
@ -55,11 +55,11 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function pushConversation(){
|
function pushConversation(){
|
||||||
|
//expectScreenUpdate=true;
|
||||||
|
showConversation(index,newsitemobject)
|
||||||
if (model.newsitemobject.hasOwnProperty("currentconversation")){
|
if (model.newsitemobject.hasOwnProperty("currentconversation")){
|
||||||
rootstackView.push("qrc:/qml/newsqml/Conversation.qml",{"news": model.newsitemobject.currentconversation})}
|
rootstackView.push("qrc:/qml/newsqml/Conversation.qml",{"news": model.newsitemobject.currentconversation})}
|
||||||
else{rootstackView.push("qrc:/qml/newsqml/Conversation.qml")};
|
else{rootstackView.push("qrc:/qml/newsqml/Conversation.qml")};
|
||||||
expectScreenUpdate=true;
|
|
||||||
showConversation(index,newsitemobject)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle{width:newsitem.width; height: 1; anchors.bottom: newsitem.bottom;
|
Rectangle{width:newsitem.width; height: 1; anchors.bottom: newsitem.bottom;
|
||||||
|
|
Loading…
Reference in a new issue