|
@ -3,9 +3,7 @@ class ApplicationController < ActionController::Base |
|
|
allow_browser versions: :modern |
|
|
allow_browser versions: :modern |
|
|
|
|
|
|
|
|
def render_stream(notice: nil, alert: nil, &) |
|
|
def render_stream(notice: nil, alert: nil, &) |
|
|
flash.now[:notice] = notice if notice |
|
|
|
|
|
flash.now[:alert] = alert if alert |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flash_now_only!(notice, alert) |
|
|
proxy_stream = ProxyStream.new(turbo_stream) |
|
|
proxy_stream = ProxyStream.new(turbo_stream) |
|
|
proxy_stream.replace(:flash, partial: 'layouts/components/flash') if flash.any? |
|
|
proxy_stream.replace(:flash, partial: 'layouts/components/flash') if flash.any? |
|
|
yield(proxy_stream) if block_given? |
|
|
yield(proxy_stream) if block_given? |
|
@ -29,4 +27,12 @@ class ApplicationController < ActionController::Base |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
private_constant(:ProxyStream) |
|
|
private_constant(:ProxyStream) |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def flash_now_only!(notice, alert) |
|
|
|
|
|
flash.discard |
|
|
|
|
|
flash.now[:notice] = notice if notice |
|
|
|
|
|
flash.now[:alert] = alert if alert |
|
|
|
|
|
end |
|
|
end |
|
|
end |