jason-rails 0.6.7 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48abc57aac9f4529a93812d46422ac21d48e58432fc21e570f1801b84a3ac436
4
- data.tar.gz: ac21dab5464e5dd254a1a223a80581c1410c928bab4c0fbc9fe32cdfedb7c474
3
+ metadata.gz: 64f8392cc200b54c7584534cedb35ccbb1675d8c15d1193152e4cbdec558a934
4
+ data.tar.gz: eb285b6c8660017fda735dee46802b9617f08c121c67ce0e9e68efb448e6765c
5
5
  SHA512:
6
- metadata.gz: '09c42d2b035af32efdc006224e3e81fa398d2327199845640ff7c710c7cecbd0c5edd9d18e441b5b3fefb2a356f45159c77194ed72f866880171071fb302c422'
7
- data.tar.gz: 1b5f4f16a5032ca96f8106dc4fff8c8a1a1d5792392b4ed28ad9f1c8974848dec5359e4bb0bc675463cc923e5f77552b6bcfda6c733bf72bb66f156648ce521c
6
+ metadata.gz: 7505f22ac0737faa51726c9ba5dbbaeab2b6634583e32e574f8e0c4ffc6ba8de4e14eb78f3184d3d9a961ac153cc396253d95ac225fc2f853ebaa6c805197d0f
7
+ data.tar.gz: 1f6b1f4472d04876566c0edb050a9890cc42b8a6ac083072de38c7d64f7f5780c9e14c1c16f7443eaf98e9ba2ef3b06f400542582c96d619bc0cb2f6645ce8e4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.6.7
2
+ - Fix: Change names of controllers to be less likely to conflict with host app inflections
3
+ - Added: Pusher now pushes asychronously via Sidekiq using the Pusher batch API
4
+
1
5
  ## v0.6.6
2
6
  - Fix: don't run the schema change detection and cache rebuild inside rake tasks or migrations
3
7
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jason-rails (0.6.6)
4
+ jason-rails (0.6.7)
5
5
  connection_pool (>= 2.2.3)
6
6
  jsondiff
7
7
  rails (>= 5)
@@ -93,7 +93,7 @@ GEM
93
93
  mini_mime (1.0.2)
94
94
  mini_portile2 (2.5.0)
95
95
  minitest (5.14.3)
96
- nio4r (2.5.5)
96
+ nio4r (2.5.7)
97
97
  nokogiri (1.11.1)
98
98
  mini_portile2 (~> 2.5.0)
99
99
  racc (~> 1.4)
data/README.md CHANGED
@@ -163,6 +163,7 @@ Similarly to authorizing subscriptions, you can do this by providing an class to
163
163
  ## Roadmap
164
164
 
165
165
  Development is primarily driven by the needs of projects we're using Jason in. In no particular order, being considered is:
166
+ - Better detection of when subscriptions drop, delete subscription
166
167
  - Failure handling - rolling back local state in case of an error on the server
167
168
  - Authorization - more thorough authorization integration, with utility functions for common authorizations. Allowing authorization of access to particular fields such as restricting the fields of a user that are publicly broadcast.
168
169
  - Utilities for "Draft editing" - both storing client-side copies of model trees which can be committed or discarded, as well as persisting a shadow copy to the database (to allow resumable editing, or possibly collaborative editing features)
@@ -73,9 +73,10 @@ function useJason({ reducers, middleware = [], extraActions }) {
73
73
  };
74
74
  }
75
75
  function removeSubscription(config) {
76
+ var _a;
76
77
  transportAdapter.removeSubscription(config);
77
78
  const md5Hash = blueimp_md5_1.default(JSON.stringify(config));
78
- payloadHandlers[md5Hash].tearDown();
79
+ (_a = payloadHandlers[md5Hash]) === null || _a === void 0 ? void 0 : _a.tearDown(); // Race condition where component mounts then unmounts quickly
79
80
  delete payloadHandlers[md5Hash];
80
81
  delete configs[md5Hash];
81
82
  delete subOptions[md5Hash];
@@ -90,7 +90,7 @@ export default function useJason({ reducers, middleware = [], extraActions }: {
90
90
  function removeSubscription(config) {
91
91
  transportAdapter.removeSubscription(config)
92
92
  const md5Hash = md5(JSON.stringify(config))
93
- payloadHandlers[md5Hash].tearDown()
93
+ payloadHandlers[md5Hash]?.tearDown() // Race condition where component mounts then unmounts quickly
94
94
  delete payloadHandlers[md5Hash]
95
95
  delete configs[md5Hash]
96
96
  delete subOptions[md5Hash]
@@ -5,6 +5,7 @@ module Jason::Publisher
5
5
  def self.cache_all
6
6
  Rails.application.eager_load!
7
7
  ActiveRecord::Base.descendants.each do |klass|
8
+ $redis_jason.del("jason:cache:#{klass.name.underscore}")
8
9
  klass.cache_all if klass.respond_to?(:cache_all)
9
10
  end
10
11
  end
@@ -117,7 +118,8 @@ module Jason::Publisher
117
118
  self.after_initialize -> {
118
119
  @api_model = Jason::ApiModel.new(self.class.name.underscore)
119
120
  }
120
- self.after_commit :publish_json_if_changed
121
+ self.after_commit :force_publish_json, on: [:create, :destroy]
122
+ self.after_commit :publish_json_if_changed, on: [:update]
121
123
  end
122
124
 
123
125
  def find_or_create_by_id(params)
@@ -48,12 +48,15 @@ class Jason::Subscription
48
48
  end
49
49
  end
50
50
 
51
+ def self.all_for_model(model_name)
52
+ $redis_jason.smembers("jason:models:#{model_name}:all:subscriptions")
53
+ end
54
+
51
55
  def self.for_instance(model_name, id, include_all = true)
52
56
  subs = $redis_jason.smembers("jason:models:#{model_name}:#{id}:subscriptions")
53
57
  if include_all
54
- subs += $redis_jason.smembers("jason:models:#{model_name}:all:subscriptions")
58
+ subs += all_for_model(model_name)
55
59
  end
56
-
57
60
  subs
58
61
  end
59
62
 
@@ -176,6 +179,13 @@ class Jason::Subscription
176
179
  subscription.broadcast_id_changeset(id_changeset)
177
180
  end
178
181
  end
182
+
183
+ all_for_model(model_name).each do |sub_id|
184
+ subscription = find_by_id(sub_id)
185
+ ids.each do |id|
186
+ subscription.destroy(model_name, id)
187
+ end
188
+ end
179
189
  end
180
190
 
181
191
  # Add ID to any _all_ subscriptions
@@ -238,7 +248,6 @@ class Jason::Subscription
238
248
  all_models = includes_helper.all_models(model_name)
239
249
 
240
250
  relation = model_name.classify.constantize.all.eager_load(includes_tree)
241
-
242
251
  if model_name == model
243
252
  if conditions.blank?
244
253
  $redis_jason.sadd("jason:models:#{model_name}:all:subscriptions", id)
@@ -287,6 +296,7 @@ class Jason::Subscription
287
296
  end
288
297
  $redis_jason.del("jason:subscriptions:#{id}:ids:#{model_name}")
289
298
  end
299
+ $redis_jason.del("jason:subscriptions:#{id}:graph")
290
300
  end
291
301
 
292
302
  def ids(model_name = model)
@@ -381,7 +391,6 @@ class Jason::Subscription
381
391
  # Remove subscription state
382
392
  if hard
383
393
  clear_all_ids
384
- $redis_jason.del("jason:subscriptions:#{id}:graph")
385
394
  end
386
395
 
387
396
  set_ids_for_sub_models(enforce: true)
data/lib/jason/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jason
2
- VERSION = "0.6.7"
2
+ VERSION = "0.6.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jason-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Rees
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-24 00:00:00.000000000 Z
11
+ date: 2021-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails