groups download

This commit is contained in:
LubuWest 2024-05-03 18:12:01 +02:00
parent 3703c116aa
commit a2cea6464c
8 changed files with 35 additions and 19 deletions

View file

@ -83,17 +83,28 @@ function requestFriends(login,database,rootwindow,callback){
function requestGroups(login,database,rootwindow,callback){
// retrieve, save and return groups. Other features currently not implemented
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
Helperjs.friendicaRequest(login,"/api/friendica/group_show",rootwindow, function (obj){
var groups=JSON.parse(obj);
db.transaction( function(tx) {
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()
});
})}
//Helperjs.friendicaRequest(login,"/api/friendica/circle_show",rootwindow, function (obj){print("obj"+obj)
db.transaction( function(tx) {
var result = tx.executeSql('DELETE from groups where username="'+login.username+'"'); // clean old groups
});
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){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);

View file

@ -80,7 +80,7 @@ Rectangle {
height: 1.7*root.fontFactor*osSettings.bigFontSize
}
TabButton {
text: qsTr("Groups")
text: qsTr("Circles")
font.pointSize: osSettings.systemFontSize
height: 1.7*root.fontFactor*osSettings.bigFontSize
}

View file

@ -82,8 +82,12 @@ Item{
anchors.right: parent.right
anchors.rightMargin:menuButton.width
onClicked: {
Newsjs.requestGroups(root.login,root.db,root,function(){
groupsGridTab.showGroups(root.login.username)})}
Newsjs.requestGroups(root.login,root.db,root,function(groups){
for (let n in groups){
groupsModel.append({"group":groups[n]});
}
//groupsGridTab.showGroups(root.login.username)})
})}
}
// MButton {
// id: newGroupButton

View file

@ -95,7 +95,7 @@ Item {
width:parent.width
font.pointSize: osSettings.systemFontSize
font.bold: account.username==login.username && friendsTabView.currentIndex==2
text: " "+qsTr("Groups")
text: " "+qsTr("Circles")
MouseArea{
anchors.fill:parent
onClicked:{

View file

@ -355,7 +355,7 @@ Page {
contactBusy.running=false;
}
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!=""){
Service.processNews(api,data)
}else{contactBusy.running=false}

View file

@ -118,7 +118,7 @@ Page {
Connections{
target: root
function onConversationChanged(){
function onConversationChanged(){print(conversation+" conversation "+JSON.stringify(root.conversation))
// if(root.conversation.length==0){
// rootstackView.pop()
// } else {

View file

@ -53,6 +53,7 @@ Page{
}
function showConversation(conversationIndex,newsitemobject){
expectScreenUpdate=true;
if(newsitemobject.messagetype==0 || newsitemobject.messagetype==3){
xhr.setAccount(login);
xhr.setApi("/api/conversation/show");

View file

@ -55,11 +55,11 @@ Item {
}
function pushConversation(){
//expectScreenUpdate=true;
showConversation(index,newsitemobject)
if (model.newsitemobject.hasOwnProperty("currentconversation")){
rootstackView.push("qrc:/qml/newsqml/Conversation.qml",{"news": model.newsitemobject.currentconversation})}
else{rootstackView.push("qrc:/qml/newsqml/Conversation.qml")};
expectScreenUpdate=true;
showConversation(index,newsitemobject)
}
Rectangle{width:newsitem.width; height: 1; anchors.bottom: newsitem.bottom;