Commit ce7c5efc262f7bd3901c259fa0988c5da87169a9

Authored by Rodrigo Souto
1 parent d45f8eba

Sort conversations by most recent after roster

Showing 1 changed file with 2 additions and 4 deletions   Show diff stats
public/javascripts/chat.js
@@ -231,6 +231,7 @@ jQuery(function($) { @@ -231,6 +231,7 @@ jQuery(function($) {
231 var jid_id = Jabber.jid_to_id(jid); 231 var jid_id = Jabber.jid_to_id(jid);
232 Jabber.insert_or_update_contact(jid, name); 232 Jabber.insert_or_update_contact(jid, name);
233 }); 233 });
  234 + sort_conversations();
234 // set up presence handler and send initial presence 235 // set up presence handler and send initial presence
235 Jabber.connection.addHandler(Jabber.on_presence, null, "presence"); 236 Jabber.connection.addHandler(Jabber.on_presence, null, "presence");
236 Jabber.send_availability_status(Jabber.presence_status); 237 Jabber.send_availability_status(Jabber.presence_status);
@@ -615,22 +616,19 @@ jQuery(function($) { @@ -615,22 +616,19 @@ jQuery(function($) {
615 Jabber.show_message(jid, from['name'], body, who, from['id'], date, offset); 616 Jabber.show_message(jid, from['name'], body, who, from['id'], date, offset);
616 }); 617 });
617 stop_fetching('.history'); 618 stop_fetching('.history');
618 - console.log('Done fetching...');  
619 ensure_scroll(jid, offset); 619 ensure_scroll(jid, offset);
620 }); 620 });
621 } 621 }
622 622
623 function move_conversation_to_the_top(jid) { 623 function move_conversation_to_the_top(jid) {
624 id = Jabber.jid_to_id(jid); 624 id = Jabber.jid_to_id(jid);
625 - console.log('Moving ' + id);  
626 - console.log(id);  
627 var link = $('#'+id); 625 var link = $('#'+id);
628 var li = link.closest('li'); 626 var li = link.closest('li');
629 var ul = link.closest('ul'); 627 var ul = link.closest('ul');
630 ul.prepend(li); 628 ul.prepend(li);
631 } 629 }
632 630
633 - function recent_conversations() { 631 + function sort_conversations() {
634 $.getJSON('/chat/recent_conversations', {}, function(data) { 632 $.getJSON('/chat/recent_conversations', {}, function(data) {
635 $.each(data['order'], function(i, identifier) { 633 $.each(data['order'], function(i, identifier) {
636 move_conversation_to_the_top(identifier+'-'+data['domain']); 634 move_conversation_to_the_top(identifier+'-'+data['domain']);