foreign_office 0.17.5 → 0.17.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10d73ea47137df4fd2ee5f9a9b7c67161c62ba5e78abf683f148a5f67463d653
4
- data.tar.gz: bb4a555e893139952195def37440a97d7cbbabcb1f7550b7dedadbaeef9bf7cd
3
+ metadata.gz: 2df33e9ed279630f8e8b5f08df6963749e7bf6051a1fc1a782f0c89ca43623ac
4
+ data.tar.gz: 814fdf748bb2d70f3e9fa2936525a677e90e640fba3d488b02985521ab4e3b87
5
5
  SHA512:
6
- metadata.gz: ad5a45b4ebb04b281d7dbdadf595666955d2fcdec102e52b2734801b6559a35f8478b7db977ce683c975d0c86da688a7477ac87c1af98ebf1f2768d71e51ee38
7
- data.tar.gz: fb40f3168cf80fc7ccf0d1a22be0c2f00bc257969ee6263f5a9898263e85b87d75c256d48963ec087c2abafbb8df56ae21b486056aed47babbbdd65feb71da59
6
+ metadata.gz: 4a48185cf5957605756c9cc0cc424066a951870a4a48152b18f8301f35332fbfa1d040e2e63387bd31c8bbbf0c2c269f9ef737eb2c793bcd006ccd0ffb3144df
7
+ data.tar.gz: fdb9b3102b5e8462ac52f9c9cb8f208b2d54a09bcd562c6c63d80fee4103ef750dcaced5cb8ed9b64c5bc2f615da9bec681a8eed50e0ded9511f5ed4300f3b8e
@@ -2,8 +2,12 @@ class PresenceChannelPublishJob < ApplicationJob
2
2
  queue_as :default
3
3
 
4
4
  def perform(obj_id, obj_class_name, serialized_state)
5
+ obj_class = obj_class_name.constantize
5
6
  serialized_state.symbolize_keys!
6
- channel_name = "presence-#{obj_class_name}#{obj_id}"
7
+ channel_name = "presence-#{obj_class.foreign_office_channel_prefix}#{obj_id}"
8
+ if browser_tab_id = serialized_state[:browser_tab_id]
9
+ channel_name += "@#{browser_tab_id}"
10
+ end
7
11
  if (!ForeignOffice.bus.connection.respond_to?(:channel_users) ||
8
12
  ForeignOffice.bus.connection.channel_users(channel_name)[:users].any?)
9
13
 
@@ -13,7 +13,7 @@ module ForeignOffice
13
13
  if self.class.channel_presence_required?
14
14
  PresenceChannelPublishJob.set(wait: 1).perform_later(id, self.class.name, self.serialize)
15
15
  else
16
- ForeignOffice.publish(channel: "#{self.class.name}#{self.id}", object: self.serialize)
16
+ ForeignOffice.publish(channel: "#{self.class.foreign_office_channel_prefix}#{self.id}", object: self.serialize)
17
17
  end
18
18
  rescue => e
19
19
  Rails.logger.error "Failed to broadcast change: #{e.inspect}"
@@ -38,6 +38,11 @@ module ForeignOffice
38
38
  def channel_presence_required?
39
39
  @channel_presence_required
40
40
  end
41
+
42
+ def foreign_office_channel_prefix
43
+ self.name.gsub(/::/,'-')
44
+ end
45
+
41
46
  end
42
47
 
43
48
  end
@@ -2,9 +2,9 @@ module ForeignOffice
2
2
  module ForeignOfficeHelper
3
3
  def listener_attrs(resource, key, reveal_hide: false, endpoint: nil, download: nil,
4
4
  trigger: nil, delete: nil, href_target: nil, create_modal: nil, mask_me: nil,
5
- exclude_value: nil, browser_tab_id: nil, presence: false )
6
- presence_prefix = presence ? 'presence-' : ''
7
- channel = "#{presence_prefix}#{resource.class.name}#{resource.id}"
5
+ exclude_value: nil, browser_tab_id: nil)
6
+ presence_prefix = resource.class.channel_presence_required? ? 'presence-' : ''
7
+ channel = "#{presence_prefix}#{resource.class.foreign_office_channel_prefix}#{resource.id}"
8
8
  channel += "@#{browser_tab_id}" if browser_tab_id
9
9
  data_attrs = "data-listener=true data-channel=#{channel}"
10
10
  if delete
@@ -24,7 +24,7 @@ module ForeignOffice
24
24
  end
25
25
 
26
26
  def progress_indicator_attrs(resource, key)
27
- data_attrs = "data-foreign-office-progress-indicator=true data-channel=#{resource.class.name}#{resource.id}"
27
+ data_attrs = "data-foreign-office-progress-indicator=true data-channel=#{resource.class.foreign_office_channel_prefix}#{resource.id}"
28
28
  data_attrs += " data-key=#{key}"
29
29
  end
30
30
 
@@ -51,9 +51,9 @@ module ForeignOffice
51
51
 
52
52
  def listener_hash(resource, key, reveal_hide: false, endpoint: nil, download: nil,
53
53
  trigger: nil, delete: nil, href_target: nil, create_modal: nil, mask_me: nil,
54
- exclude_value: nil, browser_tab_id: nil, presence: false)
55
- presence_prefix = presence ? 'presence-' : ''
56
- channel = "#{presence_prefix}#{resource.class.name}#{resource.id}"
54
+ exclude_value: nil, browser_tab_id: nil)
55
+ presence_prefix = resource.class.channel_presence_required? ? 'presence-' : ''
56
+ channel = "#{presence_prefix}#{resource.class.foreign_office_channel_prefix}#{resource.id}"
57
57
  channel += "@#{browser_tab_id}" if browser_tab_id
58
58
  hash = {listener: true, channel: channel}
59
59
  if delete
@@ -1,3 +1,3 @@
1
1
  module ForeignOffice
2
- VERSION = "0.17.5"
2
+ VERSION = "0.17.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreign_office
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.5
4
+ version: 0.17.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-10-30 00:00:00.000000000 Z
12
+ date: 2018-11-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails