Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. api.getThreadList(0, 50, function (err, arr) {
  2. /*
  3. conversations:
  4. - image: imageSrc
  5. - name: name
  6.  
  7. users:
  8. - image: thumbSrc
  9. - name: name
  10. */
  11. if(err){
  12. return console.error(err);
  13. }
  14. for(prot in arr){
  15. //console.log(arr[prot]);
  16. let conversationName;
  17. let conversationImage;
  18. let conversatonID;
  19. if(arr[prot]["isCanonicalUser"]){ //is user
  20. console.log([arr[prot]["participantIDs"][0]]);
  21. api.getUserInfo([arr[prot]["participantIDs"][0]], function(err, ret){
  22. if(err) return console.error(err);
  23. console.log(ret);
  24. for(var prop in ret) {
  25. //console.log(ret[prop].name);
  26. conversationName = ret[prop].name;
  27. conversationImage = ret[prop].thumbSrc;
  28. conversatonID = [arr[prot]["participantIDs"][0]];
  29. setTimeout(function(){}, 500);
  30. }
  31. });
  32. }else{ //is group
  33. conversationName = arr[prot]["name"];
  34. conversationImage = arr[prot]["imageSrc"];
  35. conversatonID = arr[prot]["threadID"];
  36. }
  37. let conversationDOM = $("<li>", {class: "list-group-item"});
  38. conversationDOM.append($("<img>", {class: "img-circle media-object pull-left", width: 32, height: 32, src: conversationImage}));
  39. conversationDOM.append($("<div>", {class: "media-body", html: "<strong>" + conversationName + "</strong>"}));
  40. conversationDOM.append("<p>" + conversatonID + "</p>");
  41. $("#conversations").append(conversationDOM);
  42. }
  43. });
  44.  
  45. $(".conversation").click(function () {
  46.  
  47. });
  48. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement