5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-01 22:56:07 +00:00

no recargar los posts si el sitio no fue modificado

This commit is contained in:
f 2020-05-12 12:15:28 -03:00
parent 22f7db7cc0
commit e65c8e163b

View file

@ -10,12 +10,15 @@ class PostsController < ApplicationController
@site = find_site
@category = session[:category] = params.dig(:category)
@layout = params.dig(:layout).try :to_sym
# TODO: Aplicar policy_scope
@posts = @site.posts(lang: lang)
@posts.sort_by!(:order, :date).reverse!
@usuarie = @site.usuarie? current_usuarie
fresh_when @site
# XXX: Cada vez que cambiamos un Post tocamos el sitio con lo que es
# más simple saber si hubo cambios.
if @category || @layout || stale?(@site)
# TODO: Aplicar policy_scope
@posts = @site.posts(lang: lang)
@posts.sort_by!(:order, :date).reverse!
@usuarie = @site.usuarie? current_usuarie
end
end
def show