Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- api.getThreadList(0, 50, function (err, arr) {
- /*
- conversations:
- - image: imageSrc
- - name: name
- users:
- - image: thumbSrc
- - name: name
- */
- if(err){
- return console.error(err);
- }
- for(prot in arr){
- //console.log(arr[prot]);
- let conversationName;
- let conversationImage;
- let conversatonID;
- if(arr[prot]["isCanonicalUser"]){ //is user
- console.log([arr[prot]["participantIDs"][0]]);
- api.getUserInfo([arr[prot]["participantIDs"][0]], function(err, ret){
- if(err) return console.error(err);
- console.log(ret);
- for(var prop in ret) {
- //console.log(ret[prop].name);
- conversationName = ret[prop].name;
- conversationImage = ret[prop].thumbSrc;
- conversatonID = [arr[prot]["participantIDs"][0]];
- setTimeout(function(){}, 500);
- }
- });
- }else{ //is group
- conversationName = arr[prot]["name"];
- conversationImage = arr[prot]["imageSrc"];
- conversatonID = arr[prot]["threadID"];
- }
- let conversationDOM = $("<li>", {class: "list-group-item"});
- conversationDOM.append($("<img>", {class: "img-circle media-object pull-left", width: 32, height: 32, src: conversationImage}));
- conversationDOM.append($("<div>", {class: "media-body", html: "<strong>" + conversationName + "</strong>"}));
- conversationDOM.append("<p>" + conversatonID + "</p>");
- $("#conversations").append(conversationDOM);
- }
- });
- $(".conversation").click(function () {
- });
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement