post_layout: always show or always hide (for low-bandwidth)

This commit is contained in:
freamon 2024-03-17 07:28:03 +00:00
parent a121b316d5
commit b121c13d4e

View file

@ -121,7 +121,13 @@ def show_community(community: Community):
page = request.args.get('page', 1, type=int) page = request.args.get('page', 1, type=int)
sort = request.args.get('sort', '' if current_user.is_anonymous else current_user.default_sort) sort = request.args.get('sort', '' if current_user.is_anonymous else current_user.default_sort)
low_bandwidth = request.cookies.get('low_bandwidth', '0') == '1' low_bandwidth = request.cookies.get('low_bandwidth', '0') == '1'
post_layout = request.args.get('layout', community.default_layout if not low_bandwidth else None) if low_bandwidth:
post_layout = None
else:
if community.default_layout is not None:
post_layout = request.args.get('layout', community.default_layout)
else:
post_layout = request.args.get('layout', 'list')
# If nothing has changed since their last visit, return HTTP 304 # If nothing has changed since their last visit, return HTTP 304
current_etag = f"{community.id}{sort}{post_layout}_{hash(community.last_active)}" current_etag = f"{community.id}{sort}{post_layout}_{hash(community.last_active)}"