Open catmando opened 6 years ago
this may fix it:
module ReactiveRecord
class Broadcast
def self.after_commit(operation, model)
Hyperloop::InternalPolicy.regulate_broadcast(model) do |data|
if !Hyperloop.on_server? && Hyperloop::Connection.root_path
send_to_server(operation, data)
elsif operation == :update && data[:previous_changes].empty?
SendPacket.run(data, operation: operation)
end
end
rescue ActiveRecord::StatementInvalid => e
raise e unless e.message == "Could not find table 'hyperloop_connections'"
end unless RUBY_ENGINE == 'opal'
end
end
you can't monkey patch this but a slightly cleaner (if not quite as effecient) way is to change the SendPacket operation's dispatch to be:
dispatch_to { params.channel if params.operation == :update && params.previous_changes.present? }
actually first case (patching after_commit) won't work if the change was made on the console... So best update SendPacket
when using auth_logic (for example) when a logged user makes ANY request to the server, this updates the user model, which causes data to be pushed to the client
which causes the client to update its scopes
which is another request
and so on...
so the solution should be don't sync those attributes to the client
so hyper-mesh filters out those attributes, but the problem is even if you have an empty set of attributes, the update is still being sent, causing the scope resync...