lookbook 1.5.2 → 1.5.3

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: d6dfc00bd48155e8ce1a32cd2ad27668bb1b86a179ecbcce6236ea29f7cd4ef3
4
- data.tar.gz: 30abb627e57ba885312e2b9c4a70f7cfc2a8a27dc6d5fbb6fa721dca38ae913f
3
+ metadata.gz: 7f540f127ea326803394a4fb256d8ec3f27a9f7564f003d075b5e3b70ccd0ff2
4
+ data.tar.gz: 7987f3e5caaeb9cc8ebd3e0a38fc3b2735ba3c894207320b612e15075441ac5e
5
5
  SHA512:
6
- metadata.gz: b6634bc5a89fe0b43c389bfeeaf521563d8de55fa2cf8a5778f7471a62bd69949ed79bbbc07a539b87882a0a4802515718a08e5fe7a6637f389c93b8e3bb961f
7
- data.tar.gz: 89e1af478c55cc5f62c532715432f958d8be1651531917828669104ac3b1aa74177fd14162353e583adc9632cb58529c3fa690ac8220b08006b0c568c3e8381d
6
+ metadata.gz: 4984fbeb06a7ba811cb45a0253fb9391f238c1fbe48e8cb4d2f8b32166e5551c08a9df6116b737423af6ecdd90d13bd91317189d962fc174b32e16b848f21f26
7
+ data.tar.gz: aadc14cb2bc965a03fbed65fb6824b898449567fc09574974dd4edde3c317fe52ef5ba989b9039f291a34c6ad0673471f22c9b2ce5869567a3e684d78fbdfbbe
@@ -44,14 +44,15 @@ module Lookbook
44
44
  display_params = SearchParamParser.call(params[:_display])
45
45
  display_params.each do |name, value|
46
46
  if @dynamic_display_options.key?(name)
47
- cookies["lookbook-display-#{name}"] = value
47
+ cookies["lookbook-display-#{name}"] = value.is_a?(Array) ? value[1] : value
48
48
  end
49
49
  end
50
50
  end
51
51
 
52
52
  @dynamic_display_options.each do |name, opts|
53
53
  choices = opts.is_a?(Hash) ? opts[:choices].to_a : opts
54
- @static_display_options[name] ||= cookies.fetch("lookbook-display-#{name}", choices.first)
54
+ value = choices.first.is_a?(Array) ? choices.first[1] : choices.first
55
+ @static_display_options[name] ||= cookies.fetch("lookbook-display-#{name}", value)
55
56
  end
56
57
 
57
58
  unless params[:_display]
@@ -13,7 +13,7 @@
13
13
  }",
14
14
  "@click.outside": "closeMobileSidebar",
15
15
  cloak: true do %>
16
- <% cache do %>
16
+ <% cache Lookbook::Engine.last_changed do %>
17
17
  <%= lookbook_render :split_layout,
18
18
  alpine_data: "$store.layout.#{@pages.any? && @previews.any? ? "sidebar" : "singleSectionSidebar"}",
19
19
  style: "height: calc(100vh - 2.5rem);" do |layout| %>
@@ -43,6 +43,7 @@ module Lookbook
43
43
  initializer "lookbook.file_watcher.pages" do
44
44
  file_watcher.watch(opts.page_paths, opts.page_extensions) do |changes|
45
45
  Engine.pages.load(Engine.page_paths)
46
+ Engine.mark_changed
46
47
  Engine.websocket.broadcast(:reload)
47
48
  run_hooks(:after_change, changes)
48
49
  end
@@ -51,6 +52,7 @@ module Lookbook
51
52
  initializer "lookbook.parser.previews_load_callback" do
52
53
  parser.after_parse do |code_objects|
53
54
  Engine.previews.load(code_objects.all(:class))
55
+ Engine.mark_changed
54
56
  Engine.websocket.broadcast(:reload)
55
57
  end
56
58
  end
@@ -168,6 +170,14 @@ module Lookbook
168
170
  @_previews ||= PreviewCollection.new
169
171
  end
170
172
 
173
+ def mark_changed
174
+ @_last_changed = nil
175
+ end
176
+
177
+ def last_changed
178
+ @_last_changed ||= (Time.now.to_f * 1000).to_i
179
+ end
180
+
171
181
  attr_reader :preview_controller
172
182
  end
173
183
 
@@ -1,3 +1,3 @@
1
1
  module Lookbook
2
- VERSION = "1.5.2"
2
+ VERSION = "1.5.3"
3
3
  end