Last active
November 27, 2017 17:21
-
-
Save domagude/af8e32d370326f0f2ded56ffa0c53096 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.notification = App.cable.subscriptions.create("NotificationChannel", { | |
connected: function() {}, | |
disconnected: function() {}, | |
received: function(data) { | |
// if a contact request was accepted | |
if (data['notification'] == 'accepted-contact-request') { | |
} | |
// if a contact request was declined | |
if (data['notification'] == 'declined-contact-request') { | |
} | |
// if a contact request was received | |
if (data['notification'] == 'contact-request-received') { | |
conversation_window = $('body').find('[data-pconversation-user-name="' + data["sender_name"] + '"]'); | |
has_no_contact_requests = $('#contacts-requests ul').find('.no-requests'); | |
contact_request = data['contact_request']; | |
if (has_no_contact_requests.length) { | |
// remove has no contact request message | |
has_no_contact_requests.remove(); | |
} | |
if (conversation_window.length) { | |
// remove add user to contacts button | |
conversation_window.find('.add-user-to-contacts-message').parent().remove(); | |
conversation_window.find('.add-user-to-contacts').remove(); | |
conversation_window.find('.conversation-heading').css('width', '360px'); | |
} | |
// append a new contact request | |
$('#contacts-requests ul').prepend(contact_request); | |
calculateContactRequests(); | |
} | |
}, | |
contact_request_response: function(sender_user_name, receiver_user_name, notification) { | |
return this.perform('contact_request_response', { | |
sender_user_name: sender_user_name, | |
receiver_user_name: receiver_user_name, | |
notification: notification | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment