Commit 7a83424bfb6b6dfdc9e093490b7857a14733c4d3
1 parent
80bac445
Exists in
master
and in
29 other branches
chat: open group chat properly after page reload
Showing
2 changed files
with
10 additions
and
15 deletions
Show diff stats
public/javascripts/application.js
... | ... | @@ -587,10 +587,10 @@ function display_notice(message) { |
587 | 587 | setTimeout(function() { $noticeBox.fadeOut('fast'); }, 5000); |
588 | 588 | } |
589 | 589 | |
590 | -function open_chat_window(anchor) { | |
590 | +function open_chat_window(jid) { | |
591 | 591 | jQuery('#chat').addClass('opened'); |
592 | 592 | jQuery('#chat-label').addClass('opened'); |
593 | - jQuery("#chat" ).trigger('opengroup', anchor); | |
593 | + jQuery("#chat" ).trigger('opengroup', jid); | |
594 | 594 | return false; |
595 | 595 | } |
596 | 596 | ... | ... |
public/javascripts/chat.js
... | ... | @@ -200,7 +200,7 @@ jQuery(function($) { |
200 | 200 | $.post('/chat/join', {room_id: jid}); |
201 | 201 | }, |
202 | 202 | |
203 | - leave_room: function(jid) { | |
203 | + leave_room: function(jid, push) { | |
204 | 204 | if(push == undefined) |
205 | 205 | push = true |
206 | 206 | var jid_id = Jabber.jid_to_id(jid); |
... | ... | @@ -498,7 +498,6 @@ jQuery(function($) { |
498 | 498 | .c('active', {xmlns: Strophe.NS.CHAT_STATES}); |
499 | 499 | Jabber.connection.send(message); |
500 | 500 | Jabber.show_message(jid, $own_name, escape_html(body), 'self', Strophe.getNodeFromJid(Jabber.connection.jid)); |
501 | - Archive.register(jid, Jabber.connection.jid, body); | |
502 | 501 | move_conversation_to_the_top(jid); |
503 | 502 | }, |
504 | 503 | |
... | ... | @@ -536,19 +535,16 @@ jQuery(function($) { |
536 | 535 | }); |
537 | 536 | |
538 | 537 | // detect when click in chat with a community or person in main window of Noosfero environment |
539 | - $('#chat').bind('opengroup', function(ev, anchor) { | |
540 | - var full_jid = anchor.replace('#', ''); | |
541 | - var jid = Strophe.getBareJidFromJid(full_jid); | |
542 | - console.log('>>>> '+jid); | |
543 | - var name = Strophe.getResourceFromJid(full_jid); | |
544 | - var jid_id = Jabber.jid_to_id(full_jid); | |
545 | - if (full_jid) { | |
538 | + $('#chat').bind('opengroup', function(ev, jid) { | |
539 | + var jid_id = Jabber.jid_to_id(jid); | |
540 | + var name = Jabber.name_of(jid_id); | |
541 | + if (jid) { | |
546 | 542 | if (Strophe.getDomainFromJid(jid) == Jabber.muc_domain) { |
547 | 543 | if (Jabber.muc_supported) { |
548 | 544 | log('opening groupchat with ' + jid); |
549 | 545 | Jabber.jids[jid_id] = {jid: jid, name: name, type: 'groupchat'}; |
550 | - Jabber.enter_room(jid); | |
551 | 546 | var conversation = create_conversation_tab(name, jid_id); |
547 | + Jabber.enter_room(jid); | |
552 | 548 | conversation.find('.conversation').show(); |
553 | 549 | recent_messages(jid); |
554 | 550 | } |
... | ... | @@ -701,12 +697,11 @@ jQuery(function($) { |
701 | 697 | function load_defaults() { |
702 | 698 | $.getJSON('/chat/my_session', {}, function(data) { |
703 | 699 | $.each(data.rooms, function(i, room_jid) { |
704 | - Jabber.enter_room(room_jid, false); | |
700 | + $('#chat').trigger('opengroup', room_jid); | |
705 | 701 | }) |
706 | 702 | |
707 | 703 | $('#'+data.tab_id).click(); |
708 | 704 | |
709 | - console.log(data); | |
710 | 705 | if(data.status == 'opened') |
711 | 706 | toggle_chat_window(); |
712 | 707 | }) |
... | ... | @@ -794,7 +789,7 @@ jQuery(function($) { |
794 | 789 | var options = {body: message.body, icon: avatar, tag: jid_id}; |
795 | 790 | console.log('Notify '+name); |
796 | 791 | $(notifyMe(name, options)).on('click', function(){ |
797 | - open_chat_window('#'+jid+'/'+name); | |
792 | + open_chat_window(jid); | |
798 | 793 | }); |
799 | 794 | $.sound.play('/sounds/receive.wav'); |
800 | 795 | } | ... | ... |