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
Group::MessageBroadcastJob.perform_later(message, nil, nil) |
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
// if a user was added to a new group conversation | |
if (data['notification'] == 'added-to-group-conversation') { | |
subToGroupConversationChannel(data['conversation_id']); | |
$('#conversations-menu ul').prepend(data['link_to_conversation']); | |
calculateUnseenConversations(); | |
if (gon.user_id == data['message_author']) { | |
$('#conversations-menu ul li a')[0].click(); | |
} | |
} |
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
def perform(message, previous_message, current_user) | |
# if the message's attribute added_new_users has present values | |
# broadcast a notification to those users that they were added to a group conv | |
if message.added_new_users.present? | |
conversation = message.conversation | |
message.added_new_users.each do |user_id| | |
ActionCable.server.broadcast( | |
"notifications_#{user_id}", | |
notification: 'added-to-group-conversation', | |
conversation_id: conversation.id, |
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
// on the add-user-to-contacts link click | |
// remove the link and notify, that the request has been sent | |
$(document).on('click', | |
'.add-user-to-contacts, .add-user-to-contacts-notif', | |
function(e) { | |
var conversation_window = $(this).parents('.conversation-window,\ | |
.conversation'); | |
conversation_window | |
.find('.add-user-to-contacts') | |
.replaceWith('<div class="contact-request-sent"\ |
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
after_create_commit { ContactRequestBroadcastJob.perform_later(self) } |
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
$(document).on('turbolinks:load', function() { | |
// when a contact request is accepted, mark it as accepted | |
$('body').on('click', '.accept-request a', function() { | |
var sender_user_name = $('nav #user-name').html(); | |
var receiver_user_name = $(this) | |
.parents('[data-user-name]') | |
.attr('data-user-name'); | |
var requests_menu_item = $('#contacts-requests ul'); | |
requests_menu_item = requests_menu_item |
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') { |
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
<li class="contact-request" data-user-name="<%= user.name %>"> | |
<div class="sixty-percent"> | |
<span class="contact-name"><%= user.name %></span> | |
</div> | |
<div class="forty-percent"> | |
<span class="accept-request"> | |
<%= link_to "Accept", | |
contact_path(id: user.id), | |
remote: true, | |
method: "put" %> |
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
<div class='pull-right' id='contacts-requests'> | |
<%= render 'layouts/navigation/header/dropdowns/contact_requests' %> | |
</div> |
NewerOlder