FIX: preview theme not working consistently

Avoid flash, this makes debugging much simpler as well.

Additionally URL now clearly shows you are previewing a theme.
This commit is contained in:
Sam
2018-02-23 14:33:27 +11:00
parent 4ac5fc8cd3
commit 845cec3ba0
2 changed files with 13 additions and 3 deletions

View File

@ -5,10 +5,14 @@ class Admin::ThemesController < Admin::AdminController
skip_before_action :check_xhr, only: [:show, :preview]
def self.whitelist_theme_key(user)
"whitelist_theme_key_#{user.id}"
end
def preview
@theme = Theme.find(params[:id])
redirect_to path("/"), flash: { preview_theme_key: @theme.key }
$redis.setex(Admin::ThemesController.whitelist_theme_key(current_user), 60, @theme.key)
redirect_to path("/?preview_theme_key=#{@theme.key}")
end
def upload_asset